main.mk revision 64755b9ec502e3031677c68cd257ae653987628c
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 problems 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.
41ifneq (1,$(strip $(shell expr $(MAKE_VERSION) \>= 3.81)))
42$(warning ********************************************************************************)
43$(warning *  You are using version $(MAKE_VERSION) of make.)
44$(warning *  Android can only be built by versions 3.81 and higher.)
45$(warning *  see https://source.android.com/source/download.html)
46$(warning ********************************************************************************)
47$(error stopping)
48endif
49
50# Absolute path of the present working direcotry.
51# This overrides the shell variable $PWD, which does not necessarily points to
52# the top of the source tree, for example when "make -C" is used in m/mm/mmm.
53PWD := $(shell pwd)
54
55TOP := .
56TOPDIR :=
57
58BUILD_SYSTEM := $(TOPDIR)build/core
59
60# This is the default target.  It must be the first declared target.
61.PHONY: droid
62DEFAULT_GOAL := droid
63$(DEFAULT_GOAL): droid_targets
64
65.PHONY: droid_targets
66droid_targets:
67
68# Used to force goals to build.  Only use for conditionally defined goals.
69.PHONY: FORCE
70FORCE:
71
72# These goals don't need to collect and include Android.mks/CleanSpec.mks
73# in the source tree.
74dont_bother_goals := clean clobber dataclean installclean \
75    help out \
76    snod systemimage-nodeps \
77    stnod systemtarball-nodeps \
78    userdataimage-nodeps userdatatarball-nodeps \
79    cacheimage-nodeps \
80    bptimage-nodeps \
81    vendorimage-nodeps \
82    systemotherimage-nodeps \
83    ramdisk-nodeps \
84    bootimage-nodeps \
85    recoveryimage-nodeps \
86    product-graph dump-products
87
88ifneq ($(filter $(dont_bother_goals), $(MAKECMDGOALS)),)
89dont_bother := true
90endif
91
92ORIGINAL_MAKECMDGOALS := $(MAKECMDGOALS)
93
94# Targets that provide quick help on the build system.
95include $(BUILD_SYSTEM)/help.mk
96
97# Set up various standard variables based on configuration
98# and host information.
99include $(BUILD_SYSTEM)/config.mk
100
101ifndef KATI
102ifdef USE_NINJA
103$(warning USE_NINJA is ignored. Ninja is always used.)
104endif
105
106# Mark this is a ninja build.
107$(shell mkdir -p $(OUT_DIR) && touch $(OUT_DIR)/ninja_build)
108include build/core/ninja.mk
109else # KATI
110
111include $(SOONG_MAKEVARS_MK)
112
113# Write the build number to a file so it can be read back in
114# without changing the command line every time.  Avoids rebuilds
115# when using ninja.
116$(shell mkdir -p $(OUT_DIR) && \
117    echo -n $(BUILD_NUMBER) > $(OUT_DIR)/build_number.txt && \
118    echo -n $(BUILD_DATETIME) > $(OUT_DIR)/build_date.txt)
119BUILD_NUMBER_FROM_FILE := $$(cat $(OUT_DIR)/build_number.txt)
120BUILD_DATETIME_FROM_FILE := $$(cat $(OUT_DIR)/build_date.txt)
121ifeq ($(HOST_OS),darwin)
122DATE_FROM_FILE := date -r $(BUILD_DATETIME_FROM_FILE)
123else
124DATE_FROM_FILE := date -d @$(BUILD_DATETIME_FROM_FILE)
125endif
126
127# CTS-specific config.
128-include cts/build/config.mk
129# VTS-specific config.
130-include test/vts/tools/vts-tradefed/build/config.mk
131
132# This allows us to force a clean build - included after the config.mk
133# environment setup is done, but before we generate any dependencies.  This
134# file does the rm -rf inline so the deps which are all done below will
135# be generated correctly
136include $(BUILD_SYSTEM)/cleanbuild.mk
137
138# Include the google-specific config
139-include vendor/google/build/config.mk
140
141VERSION_CHECK_SEQUENCE_NUMBER := 6
142JAVA_NOT_REQUIRED_CHECKED :=
143-include $(OUT_DIR)/versions_checked.mk
144ifneq ($(VERSION_CHECK_SEQUENCE_NUMBER)$(JAVA_NOT_REQUIRED),$(VERSIONS_CHECKED)$(JAVA_NOT_REQUIRED_CHECKED))
145
146$(info Checking build tools versions...)
147
148# check for a case sensitive file system
149ifneq (a,$(shell mkdir -p $(OUT_DIR) ; \
150                echo a > $(OUT_DIR)/casecheck.txt; \
151                    echo B > $(OUT_DIR)/CaseCheck.txt; \
152                cat $(OUT_DIR)/casecheck.txt))
153$(warning ************************************************************)
154$(warning You are building on a case-insensitive filesystem.)
155$(warning Please move your source tree to a case-sensitive filesystem.)
156$(warning ************************************************************)
157$(error Case-insensitive filesystems not supported)
158endif
159
160# Make sure that there are no spaces in the absolute path; the
161# build system can't deal with them.
162ifneq ($(words $(shell pwd)),1)
163$(warning ************************************************************)
164$(warning You are building in a directory whose absolute path contains)
165$(warning a space character:)
166$(warning $(space))
167$(warning "$(shell pwd)")
168$(warning $(space))
169$(warning Please move your source tree to a path that does not contain)
170$(warning any spaces.)
171$(warning ************************************************************)
172$(error Directory names containing spaces not supported)
173endif
174
175ifneq ($(JAVA_NOT_REQUIRED),true)
176java_version_str := $(shell unset _JAVA_OPTIONS && java -version 2>&1)
177javac_version_str := $(shell unset _JAVA_OPTIONS && javac -version 2>&1)
178
179# Check for the correct version of java, should be 1.8 by
180# default and only 1.7 if LEGACY_USE_JAVA7 is set.
181ifeq ($(LEGACY_USE_JAVA7),) # if LEGACY_USE_JAVA7 == ''
182required_version := "1.8.x"
183required_javac_version := "1.8"
184java_version := $(shell echo '$(java_version_str)' | grep '[ "]1\.8[\. "$$]')
185javac_version := $(shell echo '$(javac_version_str)' | grep '[ "]1\.8[\. "$$]')
186else
187required_version := "1.7.x"
188required_javac_version := "1.7"
189java_version := $(shell echo '$(java_version_str)' | grep '^java .*[ "]1\.7[\. "$$]')
190javac_version := $(shell echo '$(javac_version_str)' | grep '[ "]1\.7[\. "$$]')
191endif # if LEGACY_USE_JAVA7 == ''
192
193ifeq ($(strip $(java_version)),)
194$(info ************************************************************)
195$(info You are attempting to build with the incorrect version)
196$(info of java.)
197$(info $(space))
198$(info Your version is: $(java_version_str).)
199$(info The required version is: $(required_version))
200$(info $(space))
201$(info Please follow the machine setup instructions at)
202$(info $(space)$(space)$(space)$(space)https://source.android.com/source/initializing.html)
203$(info ************************************************************)
204$(error stop)
205endif
206
207# Check for the current JDK.
208#
209# For Java 1.7/1.8, we require OpenJDK on linux and Oracle JDK on Mac OS.
210requires_openjdk := false
211ifeq ($(BUILD_OS),linux)
212requires_openjdk := true
213endif
214
215
216# Check for the current jdk
217ifeq ($(requires_openjdk), true)
218# The user asked for openjdk, so check that the host
219# java version is really openjdk and not some other JDK.
220ifeq ($(shell echo '$(java_version_str)' | grep -i openjdk),)
221$(info ************************************************************)
222$(info You asked for an OpenJDK based build but your version is)
223$(info $(java_version_str).)
224$(info ************************************************************)
225$(error stop)
226endif # java version is not OpenJdk
227else # if requires_openjdk
228ifneq ($(shell echo '$(java_version_str)' | grep -i openjdk),)
229$(info ************************************************************)
230$(info You are attempting to build with an unsupported JDK.)
231$(info $(space))
232$(info You use OpenJDK but only Sun/Oracle JDK is supported.)
233$(info Please follow the machine setup instructions at)
234$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
235$(info ************************************************************)
236$(error stop)
237endif # java version is not Sun Oracle JDK
238endif # if requires_openjdk
239
240KNOWN_INCOMPATIBLE_JAVAC_VERSIONS := google
241incompat_javac := $(foreach v,$(KNOWN_INCOMPATIBLE_JAVAC_VERSIONS),$(findstring $(v),$(javac_version_str)))
242ifneq ($(incompat_javac),)
243javac_version :=
244endif
245
246# Check for the correct version of javac
247ifeq ($(strip $(javac_version)),)
248$(info ************************************************************)
249$(info You are attempting to build with the incorrect version)
250$(info of javac.)
251$(info $(space))
252$(info Your version is: $(javac_version_str).)
253ifneq ($(incompat_javac),)
254$(info This '$(incompat_javac)' version is not supported for Android platform builds.)
255$(info Use a publicly available JDK and make sure you have run envsetup.sh / lunch.)
256else
257$(info The required version is: $(required_javac_version))
258endif
259$(info $(space))
260$(info Please follow the machine setup instructions at)
261$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
262$(info ************************************************************)
263$(error stop)
264endif
265
266endif # if JAVA_NOT_REQUIRED
267
268ifndef BUILD_EMULATOR
269  # Emulator binaries are now provided under prebuilts/android-emulator/
270  BUILD_EMULATOR := false
271endif
272
273$(shell echo 'VERSIONS_CHECKED := $(VERSION_CHECK_SEQUENCE_NUMBER)' \
274        > $(OUT_DIR)/versions_checked.mk)
275$(shell echo 'BUILD_EMULATOR ?= $(BUILD_EMULATOR)' \
276        >> $(OUT_DIR)/versions_checked.mk)
277$(shell echo 'JAVA_NOT_REQUIRED_CHECKED := $(JAVA_NOT_REQUIRED)' \
278        >> $(OUT_DIR)/versions_checked.mk)
279endif
280
281# These are the modifier targets that don't do anything themselves, but
282# change the behavior of the build.
283# (must be defined before including definitions.make)
284INTERNAL_MODIFIER_TARGETS := showcommands all
285
286# EMMA_INSTRUMENT_STATIC merges the static emma library to each emma-enabled module.
287ifeq (true,$(EMMA_INSTRUMENT_STATIC))
288EMMA_INSTRUMENT := true
289endif
290
291# Bring in standard build system definitions.
292include $(BUILD_SYSTEM)/definitions.mk
293
294# Bring in dex_preopt.mk
295include $(BUILD_SYSTEM)/dex_preopt.mk
296
297ifneq ($(filter user userdebug eng,$(MAKECMDGOALS)),)
298$(info ***************************************************************)
299$(info ***************************************************************)
300$(info Do not pass '$(filter user userdebug eng,$(MAKECMDGOALS))' on \
301       the make command line.)
302$(info Set TARGET_BUILD_VARIANT in buildspec.mk, or use lunch or)
303$(info choosecombo.)
304$(info ***************************************************************)
305$(info ***************************************************************)
306$(error stopping)
307endif
308
309ifneq ($(filter-out $(INTERNAL_VALID_VARIANTS),$(TARGET_BUILD_VARIANT)),)
310$(info ***************************************************************)
311$(info ***************************************************************)
312$(info Invalid variant: $(TARGET_BUILD_VARIANT))
313$(info Valid values are: $(INTERNAL_VALID_VARIANTS))
314$(info ***************************************************************)
315$(info ***************************************************************)
316$(error stopping)
317endif
318
319# -----------------------------------------------------------------
320# Variable to check java support level inside PDK build.
321# Not necessary if the components is not in PDK.
322# not defined : not supported
323# "sdk" : sdk API only
324# "platform" : platform API supproted
325TARGET_BUILD_JAVA_SUPPORT_LEVEL := platform
326
327# -----------------------------------------------------------------
328# The pdk (Platform Development Kit) build
329include build/core/pdk_config.mk
330
331#
332# -----------------------------------------------------------------
333# Jack version configuration
334-include $(TOPDIR)prebuilts/sdk/tools/jack_versions.mk
335-include $(TOPDIR)prebuilts/sdk/tools/jack_for_module.mk
336
337#
338# -----------------------------------------------------------------
339# Install and start Jack server
340-include $(TOPDIR)prebuilts/sdk/tools/jack_server_setup.mk
341
342#
343# -----------------------------------------------------------------
344# Jacoco package name for Jack
345-include $(TOPDIR)external/jacoco/config.mk
346
347#
348# -----------------------------------------------------------------
349# Enable dynamic linker developer warnings for all builds except
350# final release.
351ifneq ($(PLATFORM_VERSION_CODENAME),REL)
352  ADDITIONAL_BUILD_PROPERTIES += ro.bionic.ld.warning=1
353endif
354
355# -----------------------------------------------------------------
356###
357### In this section we set up the things that are different
358### between the build variants
359###
360
361is_sdk_build :=
362
363ifneq ($(filter sdk win_sdk sdk_addon,$(MAKECMDGOALS)),)
364is_sdk_build := true
365endif
366
367# Add build properties for ART. These define system properties used by installd
368# to pass flags to dex2oat.
369ADDITIONAL_BUILD_PROPERTIES += persist.sys.dalvik.vm.lib.2=libart.so
370ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.isa.$(TARGET_ARCH).variant=$(DEX2OAT_TARGET_CPU_VARIANT)
371ifneq ($(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES),)
372  ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.isa.$(TARGET_ARCH).features=$(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)
373endif
374
375ifdef TARGET_2ND_ARCH
376  ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.isa.$(TARGET_2ND_ARCH).variant=$($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT)
377  ifneq ($($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES),)
378    ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.isa.$(TARGET_2ND_ARCH).features=$($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)
379  endif
380endif
381
382## user/userdebug ##
383
384user_variant := $(filter user userdebug,$(TARGET_BUILD_VARIANT))
385enable_target_debugging := true
386tags_to_install :=
387ifneq (,$(user_variant))
388  # Target is secure in user builds.
389  ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=1
390  ADDITIONAL_DEFAULT_PROPERTIES += security.perf_harden=1
391
392  ifeq ($(user_variant),user)
393    ADDITIONAL_DEFAULT_PROPERTIES += ro.adb.secure=1
394  endif
395
396  ifeq ($(user_variant),userdebug)
397    # Pick up some extra useful tools
398    tags_to_install += debug
399  else
400    # Disable debugging in plain user builds.
401    enable_target_debugging :=
402  endif
403
404  # Disallow mock locations by default for user builds
405  ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=0
406
407else # !user_variant
408  # Turn on checkjni for non-user builds.
409  ADDITIONAL_BUILD_PROPERTIES += ro.kernel.android.checkjni=1
410  # Set device insecure for non-user builds.
411  ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0
412  # Allow mock locations by default for non user builds
413  ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=1
414endif # !user_variant
415
416ifeq (true,$(strip $(enable_target_debugging)))
417  # Target is more debuggable and adbd is on by default
418  ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1
419  # Enable Dalvik lock contention logging.
420  ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.lockprof.threshold=500
421  # Include the debugging/testing OTA keys in this build.
422  INCLUDE_TEST_OTA_KEYS := true
423else # !enable_target_debugging
424  # Target is less debuggable and adbd is off by default
425  ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0
426endif # !enable_target_debugging
427
428## eng ##
429
430ifeq ($(TARGET_BUILD_VARIANT),eng)
431tags_to_install := debug eng
432ifneq ($(filter ro.setupwizard.mode=ENABLED, $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))),)
433  # Don't require the setup wizard on eng builds
434  ADDITIONAL_BUILD_PROPERTIES := $(filter-out ro.setupwizard.mode=%,\
435          $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))) \
436          ro.setupwizard.mode=OPTIONAL
437endif
438ifndef is_sdk_build
439  # To speedup startup of non-preopted builds, don't verify or compile the boot image.
440  ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.image-dex2oat-filter=verify-at-runtime
441endif
442endif
443
444## sdk ##
445
446ifdef is_sdk_build
447
448# Detect if we want to build a repository for the SDK
449sdk_repo_goal := $(strip $(filter sdk_repo,$(MAKECMDGOALS)))
450MAKECMDGOALS := $(strip $(filter-out sdk_repo,$(MAKECMDGOALS)))
451
452ifneq ($(words $(sort $(filter-out $(INTERNAL_MODIFIER_TARGETS) checkbuild emulator_tests target-files-package,$(MAKECMDGOALS)))),1)
453$(error The 'sdk' target may not be specified with any other targets)
454endif
455
456# TODO: this should be eng I think.  Since the sdk is built from the eng
457# variant.
458tags_to_install := debug eng
459ADDITIONAL_BUILD_PROPERTIES += xmpp.auto-presence=true
460ADDITIONAL_BUILD_PROPERTIES += ro.config.nocheckin=yes
461else # !sdk
462endif
463
464BUILD_WITHOUT_PV := true
465
466ADDITIONAL_BUILD_PROPERTIES += net.bt.name=Android
467
468# enable vm tracing in files for now to help track
469# the cause of ANRs in the content process
470ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.stack-trace-file=/data/anr/traces.txt
471
472# ------------------------------------------------------------
473# Define a function that, given a list of module tags, returns
474# non-empty if that module should be installed in /system.
475
476# For most goals, anything not tagged with the "tests" tag should
477# be installed in /system.
478define should-install-to-system
479$(if $(filter tests,$(1)),,true)
480endef
481
482ifdef is_sdk_build
483# For the sdk goal, anything with the "samples" tag should be
484# installed in /data even if that module also has "eng"/"debug"/"user".
485define should-install-to-system
486$(if $(filter samples tests,$(1)),,true)
487endef
488endif
489
490
491# If they only used the modifier goals (showcommands, etc), we'll actually
492# build the default target.
493ifeq ($(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS)),)
494.PHONY: $(INTERNAL_MODIFIER_TARGETS)
495$(INTERNAL_MODIFIER_TARGETS): $(DEFAULT_GOAL)
496endif
497
498#
499# Typical build; include any Android.mk files we can find.
500#
501
502FULL_BUILD := true
503
504# Before we go and include all of the module makefiles, stash away
505# the PRODUCT_* values so that later we can verify they are not modified.
506stash_product_vars:=true
507ifeq ($(stash_product_vars),true)
508  $(call stash-product-vars, __STASHED)
509endif
510
511ifneq ($(ONE_SHOT_MAKEFILE),)
512# We've probably been invoked by the "mm" shell function
513# with a subdirectory's makefile.
514include $(SOONG_ANDROID_MK) $(wildcard $(ONE_SHOT_MAKEFILE))
515# Change CUSTOM_MODULES to include only modules that were
516# defined by this makefile; this will install all of those
517# modules as a side-effect.  Do this after including ONE_SHOT_MAKEFILE
518# so that the modules will be installed in the same place they
519# would have been with a normal make.
520CUSTOM_MODULES := $(sort $(call get-tagged-modules,$(ALL_MODULE_TAGS)))
521FULL_BUILD :=
522# Stub out the notice targets, which probably aren't defined
523# when using ONE_SHOT_MAKEFILE.
524NOTICE-HOST-%: ;
525NOTICE-TARGET-%: ;
526
527# A helper goal printing out install paths
528.PHONY: GET-INSTALL-PATH
529GET-INSTALL-PATH:
530	@echo "Install paths for modules in $(ONE_SHOT_MAKEFILE):"
531	@$(foreach m, $(ALL_MODULES), $(if $(ALL_MODULES.$(m).INSTALLED), \
532		echo 'INSTALL-PATH: $(m) $(ALL_MODULES.$(m).INSTALLED)';))
533
534else # ONE_SHOT_MAKEFILE
535
536ifneq ($(dont_bother),true)
537#
538# Include all of the makefiles in the system
539#
540
541subdir_makefiles := $(SOONG_ANDROID_MK) $(call first-makefiles-under,$(TOP))
542
543$(foreach mk,$(subdir_makefiles),$(info including $(mk) ...)$(eval include $(mk)))
544
545ifdef PDK_FUSION_PLATFORM_ZIP
546# Bring in the PDK platform.zip modules.
547include $(BUILD_SYSTEM)/pdk_fusion_modules.mk
548endif # PDK_FUSION_PLATFORM_ZIP
549
550endif # dont_bother
551
552endif # ONE_SHOT_MAKEFILE
553
554# Now with all Android.mks loaded we can do post cleaning steps.
555include $(BUILD_SYSTEM)/post_clean.mk
556
557ifeq ($(stash_product_vars),true)
558  $(call assert-product-vars, __STASHED)
559endif
560
561# -------------------------------------------------------------------
562# All module makefiles have been included at this point.
563# -------------------------------------------------------------------
564
565
566# -------------------------------------------------------------------
567# Fix up CUSTOM_MODULES to refer to installed files rather than
568# just bare module names.  Leave unknown modules alone in case
569# they're actually full paths to a particular file.
570known_custom_modules := $(filter $(ALL_MODULES),$(CUSTOM_MODULES))
571unknown_custom_modules := $(filter-out $(ALL_MODULES),$(CUSTOM_MODULES))
572CUSTOM_MODULES := \
573	$(call module-installed-files,$(known_custom_modules)) \
574	$(unknown_custom_modules)
575
576# -------------------------------------------------------------------
577# Define dependencies for modules that require other modules.
578# This can only happen now, after we've read in all module makefiles.
579#
580# TODO: deal with the fact that a bare module name isn't
581# unambiguous enough.  Maybe declare short targets like
582# APPS:Quake or HOST:SHARED_LIBRARIES:libutils.
583# BUG: the system image won't know to depend on modules that are
584# brought in as requirements of other modules.
585#
586# Resolve the required module name to 32-bit or 64-bit variant.
587# Get a list of corresponding 32-bit module names, if one exists.
588ifneq ($(TARGET_TRANSLATE_2ND_ARCH),true)
589define get-32-bit-modules
590$(sort $(foreach m,$(1),\
591  $(if $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).CLASS),\
592    $(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX))\
593  $(if $(ALL_MODULES.$(m)$(HOST_2ND_ARCH_MODULE_SUFFIX).CLASS),\
594    $(m)$(HOST_2ND_ARCH_MODULE_SUFFIX))\
595    ))
596endef
597# Get a list of corresponding 32-bit module names, if one exists;
598# otherwise return the original module name
599define get-32-bit-modules-if-we-can
600$(sort $(foreach m,$(1),\
601  $(if $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).CLASS)$(ALL_MODULES.$(m)$(HOST_2ND_ARCH_MODULE_SUFFIX).CLASS),\
602    $(if $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).CLASS),$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX)) \
603    $(if $(ALL_MODULES.$(m)$(HOST_2ND_ARCH_MODULE_SUFFIX).CLASS),$(m)$(HOST_2ND_ARCH_MODULE_SUFFIX)),\
604  $(m))))
605endef
606else  # TARGET_TRANSLATE_2ND_ARCH
607# For binary translation config, by default only install the first arch.
608define get-32-bit-modules
609endef
610
611define get-32-bit-modules-if-we-can
612$(strip $(1))
613endef
614endif  # TARGET_TRANSLATE_2ND_ARCH
615
616# If a module is for a cross host os, the required modules must be for
617# that OS too.
618# If a module is built for 32-bit, the required modules must be 32-bit too;
619# Otherwise if the module is an exectuable or shared library,
620#   the required modules must be 64-bit;
621#   otherwise we require both 64-bit and 32-bit variant, if one exists.
622$(foreach m,$(ALL_MODULES),\
623  $(eval r := $(ALL_MODULES.$(m).REQUIRED))\
624  $(if $(r),\
625    $(if $(ALL_MODULES.$(m).FOR_HOST_CROSS),\
626      $(eval r := $(addprefix host_cross_,$(r))))\
627    $(if $(ALL_MODULES.$(m).FOR_2ND_ARCH),\
628      $(eval r_r := $(call get-32-bit-modules-if-we-can,$(r))),\
629      $(if $(filter EXECUTABLES SHARED_LIBRARIES NATIVE_TESTS,$(ALL_MODULES.$(m).CLASS)),\
630        $(eval r_r := $(r)),\
631        $(eval r_r := $(r) $(call get-32-bit-modules,$(r)))\
632       )\
633     )\
634     $(eval ALL_MODULES.$(m).REQUIRED := $(strip $(r_r)))\
635  )\
636)
637r_r :=
638
639define add-required-deps
640$(1): | $(2)
641endef
642
643$(foreach m,$(ALL_MODULES), \
644  $(eval r := $(ALL_MODULES.$(m).REQUIRED)) \
645  $(if $(r), \
646    $(eval r := $(call module-installed-files,$(r))) \
647    $(eval t_m := $(filter $(TARGET_OUT_ROOT)/%, $(ALL_MODULES.$(m).INSTALLED))) \
648    $(eval h_m := $(filter $(HOST_OUT_ROOT)/%, $(ALL_MODULES.$(m).INSTALLED))) \
649    $(eval hc_m := $(filter $(HOST_CROSS_OUT_ROOT)/%, $(ALL_MODULES.$(m).INSTALLED))) \
650    $(eval t_r := $(filter $(TARGET_OUT_ROOT)/%, $(r))) \
651    $(eval h_r := $(filter $(HOST_OUT_ROOT)/%, $(r))) \
652    $(eval hc_r := $(filter $(HOST_CROSS_OUT_ROOT)/%, $(r))) \
653    $(eval t_m := $(filter-out $(t_r), $(t_m))) \
654    $(eval h_m := $(filter-out $(h_r), $(h_m))) \
655    $(eval hc_m := $(filter-out $(hc_r), $(hc_m))) \
656    $(if $(t_m), $(eval $(call add-required-deps, $(t_m),$(t_r)))) \
657    $(if $(h_m), $(eval $(call add-required-deps, $(h_m),$(h_r)))) \
658    $(if $(hc_m), $(eval $(call add-required-deps, $(hc_m),$(hc_r)))) \
659   ) \
660 )
661
662t_m :=
663h_m :=
664hc_m :=
665t_r :=
666h_r :=
667hc_r :=
668
669# Establish the dependecies on the shared libraries.
670# It also adds the shared library module names to ALL_MODULES.$(m).REQUIRED,
671# so they can be expanded to product_MODULES later.
672# $(1): TARGET_ or HOST_ or HOST_CROSS_.
673# $(2): non-empty for 2nd arch.
674# $(3): non-empty for host cross compile.
675define resolve-shared-libs-depes
676$(foreach m,$($(if $(2),$($(1)2ND_ARCH_VAR_PREFIX))$(1)DEPENDENCIES_ON_SHARED_LIBRARIES),\
677  $(eval p := $(subst :,$(space),$(m)))\
678  $(eval mod := $(firstword $(p)))\
679  $(eval deps := $(subst $(comma),$(space),$(lastword $(p))))\
680  $(if $(2),$(eval deps := $(addsuffix $($(1)2ND_ARCH_MODULE_SUFFIX),$(deps))))\
681  $(if $(3),$(eval deps := $(addprefix host_cross_,$(deps))))\
682  $(eval r := $(filter $($(1)OUT)/%,$(call module-installed-files,\
683    $(deps))))\
684  $(eval $(call add-required-deps,$(word 2,$(p)),$(r)))\
685  $(eval ALL_MODULES.$(mod).REQUIRED += $(deps)))
686endef
687
688$(call resolve-shared-libs-depes,TARGET_)
689ifdef TARGET_2ND_ARCH
690$(call resolve-shared-libs-depes,TARGET_,true)
691endif
692$(call resolve-shared-libs-depes,HOST_)
693ifdef HOST_2ND_ARCH
694$(call resolve-shared-libs-depes,HOST_,true)
695endif
696ifdef HOST_CROSS_OS
697$(call resolve-shared-libs-depes,HOST_CROSS_,,true)
698endif
699
700m :=
701r :=
702p :=
703deps :=
704add-required-deps :=
705
706# -------------------------------------------------------------------
707# Figure out our module sets.
708#
709# Of the modules defined by the component makefiles,
710# determine what we actually want to build.
711
712###########################################################
713## Expand a module name list with REQUIRED modules
714###########################################################
715# $(1): The variable name that holds the initial module name list.
716#       the variable will be modified to hold the expanded results.
717# $(2): The initial module name list.
718# Returns empty string (maybe with some whitespaces).
719define expand-required-modules
720$(eval _erm_new_modules := $(sort $(filter-out $($(1)),\
721  $(foreach m,$(2),$(ALL_MODULES.$(m).REQUIRED)))))\
722$(if $(_erm_new_modules),$(eval $(1) += $(_erm_new_modules))\
723  $(call expand-required-modules,$(1),$(_erm_new_modules)))
724endef
725
726ifdef FULL_BUILD
727  # The base list of modules to build for this product is specified
728  # by the appropriate product definition file, which was included
729  # by product_config.mk.
730  product_MODULES := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES)
731  # Filter out the overridden packages before doing expansion
732  product_MODULES := $(filter-out $(foreach p, $(product_MODULES), \
733      $(PACKAGES.$(p).OVERRIDES)), $(product_MODULES))
734
735  # Resolve the :32 :64 module name
736  modules_32 := $(patsubst %:32,%,$(filter %:32, $(product_MODULES)))
737  modules_64 := $(patsubst %:64,%,$(filter %:64, $(product_MODULES)))
738  modules_rest := $(filter-out %:32 %:64,$(product_MODULES))
739  # Note for 32-bit product, $(modules_32) and $(modules_64) will be
740  # added as their original module names.
741  product_MODULES := $(call get-32-bit-modules-if-we-can, $(modules_32))
742  product_MODULES += $(modules_64)
743  # For the rest we add both
744  product_MODULES += $(call get-32-bit-modules, $(modules_rest))
745  product_MODULES += $(modules_rest)
746
747  $(call expand-required-modules,product_MODULES,$(product_MODULES))
748
749  product_FILES := $(call module-installed-files, $(product_MODULES))
750  ifeq (0,1)
751    $(info product_FILES for $(TARGET_DEVICE) ($(INTERNAL_PRODUCT)):)
752    $(foreach p,$(product_FILES),$(info :   $(p)))
753    $(error done)
754  endif
755else
756  # We're not doing a full build, and are probably only including
757  # a subset of the module makefiles.  Don't try to build any modules
758  # requested by the product, because we probably won't have rules
759  # to build them.
760  product_FILES :=
761endif
762
763eng_MODULES := $(sort \
764        $(call get-tagged-modules,eng) \
765        $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_ENG)) \
766    )
767debug_MODULES := $(sort \
768        $(call get-tagged-modules,debug) \
769        $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_DEBUG)) \
770    )
771tests_MODULES := $(sort \
772        $(call get-tagged-modules,tests) \
773        $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_TESTS)) \
774    )
775
776# TODO: Remove the 3 places in the tree that use ALL_DEFAULT_INSTALLED_MODULES
777# and get rid of it from this list.
778modules_to_install := $(sort \
779    $(ALL_DEFAULT_INSTALLED_MODULES) \
780    $(product_FILES) \
781    $(foreach tag,$(tags_to_install),$($(tag)_MODULES)) \
782    $(CUSTOM_MODULES) \
783  )
784
785# Some packages may override others using LOCAL_OVERRIDES_PACKAGES.
786# Filter out (do not install) any overridden packages.
787overridden_packages := $(call get-package-overrides,$(modules_to_install))
788ifdef overridden_packages
789#  old_modules_to_install := $(modules_to_install)
790  modules_to_install := \
791      $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk %/$(p).odex), \
792          $(modules_to_install))
793endif
794#$(error filtered out
795#           $(filter-out $(modules_to_install),$(old_modules_to_install)))
796
797# Don't include any GNU General Public License shared objects or static
798# libraries in SDK images.  GPL executables (not static/dynamic libraries)
799# are okay if they don't link against any closed source libraries (directly
800# or indirectly)
801
802# It's ok (and necessary) to build the host tools, but nothing that's
803# going to be installed on the target (including static libraries).
804
805ifdef is_sdk_build
806  target_gnu_MODULES := \
807              $(filter \
808                      $(TARGET_OUT_INTERMEDIATES)/% \
809                      $(TARGET_OUT)/% \
810                      $(TARGET_OUT_DATA)/%, \
811                              $(sort $(call get-tagged-modules,gnu)))
812  target_gnu_MODULES := $(filter-out $(TARGET_OUT_EXECUTABLES)/%,$(target_gnu_MODULES))
813  $(info Removing from sdk:)$(foreach d,$(target_gnu_MODULES),$(info : $(d)))
814  modules_to_install := \
815              $(filter-out $(target_gnu_MODULES),$(modules_to_install))
816
817  # Ensure every module listed in PRODUCT_PACKAGES* gets something installed
818  # TODO: Should we do this for all builds and not just the sdk?
819  dangling_modules :=
820  $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES), \
821    $(if $(strip $(ALL_MODULES.$(m).INSTALLED) $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).INSTALLED)),,\
822      $(eval dangling_modules += $(m))))
823  ifneq ($(dangling_modules),)
824    $(warning: Modules '$(dangling_modules)' in PRODUCT_PACKAGES have nothing to install!)
825  endif
826  $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_DEBUG), \
827    $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\
828      $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_DEBUG has nothing to install!)))
829  $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_ENG), \
830    $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\
831      $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_ENG has nothing to install!)))
832  $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_TESTS), \
833    $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\
834      $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_TESTS has nothing to install!)))
835endif
836
837# build/core/Makefile contains extra stuff that we don't want to pollute this
838# top-level makefile with.  It expects that ALL_DEFAULT_INSTALLED_MODULES
839# contains everything that's built during the current make, but it also further
840# extends ALL_DEFAULT_INSTALLED_MODULES.
841ALL_DEFAULT_INSTALLED_MODULES := $(modules_to_install)
842include $(BUILD_SYSTEM)/Makefile
843modules_to_install := $(sort $(ALL_DEFAULT_INSTALLED_MODULES))
844ALL_DEFAULT_INSTALLED_MODULES :=
845
846
847# These are additional goals that we build, in order to make sure that there
848# is as little code as possible in the tree that doesn't build.
849modules_to_check := $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).CHECKED))
850
851# If you would like to build all goals, and not skip any intermediate
852# steps, you can pass the "all" modifier goal on the commandline.
853ifneq ($(filter all,$(MAKECMDGOALS)),)
854modules_to_check += $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).BUILT))
855endif
856
857# for easier debugging
858modules_to_check := $(sort $(modules_to_check))
859#$(error modules_to_check $(modules_to_check))
860
861# -------------------------------------------------------------------
862# This is used to to get the ordering right, you can also use these,
863# but they're considered undocumented, so don't complain if their
864# behavior changes.
865# An internal target that depends on all copied headers
866# (see copy_headers.make).  Other targets that need the
867# headers to be copied first can depend on this target.
868.PHONY: all_copied_headers
869all_copied_headers: ;
870
871$(ALL_C_CPP_ETC_OBJECTS): | all_copied_headers
872
873# All the droid stuff, in directories
874.PHONY: files
875files: $(modules_to_install) \
876       $(INSTALLED_ANDROID_INFO_TXT_TARGET)
877
878# -------------------------------------------------------------------
879
880.PHONY: checkbuild
881checkbuild: $(modules_to_check) droid_targets
882checkbuild: checkbuild-soong
883
884ifeq (true,$(ANDROID_BUILD_EVERYTHING_BY_DEFAULT))
885droid: checkbuild
886endif
887
888.PHONY: ramdisk
889ramdisk: $(INSTALLED_RAMDISK_TARGET)
890
891.PHONY: systemtarball
892systemtarball: $(INSTALLED_SYSTEMTARBALL_TARGET)
893
894.PHONY: boottarball
895boottarball: $(INSTALLED_BOOTTARBALL_TARGET)
896
897.PHONY: userdataimage
898userdataimage: $(INSTALLED_USERDATAIMAGE_TARGET)
899
900ifneq (,$(filter userdataimage, $(MAKECMDGOALS)))
901$(call dist-for-goals, userdataimage, $(BUILT_USERDATAIMAGE_TARGET))
902endif
903
904.PHONY: userdatatarball
905userdatatarball: $(INSTALLED_USERDATATARBALL_TARGET)
906
907.PHONY: cacheimage
908cacheimage: $(INSTALLED_CACHEIMAGE_TARGET)
909
910.PHONY: bptimage
911bptimage: $(INSTALLED_BPTIMAGE_TARGET)
912
913.PHONY: vendorimage
914vendorimage: $(INSTALLED_VENDORIMAGE_TARGET)
915
916.PHONY: systemotherimage
917systemotherimage: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
918
919.PHONY: bootimage
920bootimage: $(INSTALLED_BOOTIMAGE_TARGET)
921
922# phony target that include any targets in $(ALL_MODULES)
923.PHONY: all_modules
924ifndef BUILD_MODULES_IN_PATHS
925all_modules: $(ALL_MODULES)
926else
927# BUILD_MODULES_IN_PATHS is a list of paths relative to the top of the tree
928build_modules_in_paths := $(patsubst ./%,%,$(BUILD_MODULES_IN_PATHS))
929module_path_patterns := $(foreach p, $(build_modules_in_paths),\
930    $(if $(filter %/,$(p)),$(p)%,$(p)/%))
931my_all_modules := $(sort $(foreach m, $(ALL_MODULES),$(if $(filter\
932    $(module_path_patterns), $(addsuffix /,$(ALL_MODULES.$(m).PATH))),$(m))))
933all_modules: $(my_all_modules)
934endif
935
936
937# Build files and then package it into the rom formats
938.PHONY: droidcore
939droidcore: files \
940	systemimage \
941	$(INSTALLED_BOOTIMAGE_TARGET) \
942	$(INSTALLED_RECOVERYIMAGE_TARGET) \
943	$(INSTALLED_USERDATAIMAGE_TARGET) \
944	$(INSTALLED_CACHEIMAGE_TARGET) \
945	$(INSTALLED_BPTIMAGE_TARGET) \
946	$(INSTALLED_VENDORIMAGE_TARGET) \
947	$(INSTALLED_SYSTEMOTHERIMAGE_TARGET) \
948	$(INSTALLED_FILES_FILE) \
949	$(INSTALLED_FILES_FILE_VENDOR) \
950	$(INSTALLED_FILES_FILE_SYSTEMOTHER)
951
952# dist_files only for putting your library into the dist directory with a full build.
953.PHONY: dist_files
954
955ifneq ($(TARGET_BUILD_APPS),)
956  # If this build is just for apps, only build apps and not the full system by default.
957
958  unbundled_build_modules :=
959  ifneq ($(filter all,$(TARGET_BUILD_APPS)),)
960    # If they used the magic goal "all" then build all apps in the source tree.
961    unbundled_build_modules := $(foreach m,$(sort $(ALL_MODULES)),$(if $(filter APPS,$(ALL_MODULES.$(m).CLASS)),$(m)))
962  else
963    unbundled_build_modules := $(TARGET_BUILD_APPS)
964  endif
965
966  # Dist the installed files if they exist.
967  apps_only_installed_files := $(foreach m,$(unbundled_build_modules),$(ALL_MODULES.$(m).INSTALLED))
968  $(call dist-for-goals,apps_only, $(apps_only_installed_files))
969  # For uninstallable modules such as static Java library, we have to dist the built file,
970  # as <module_name>.<suffix>
971  apps_only_dist_built_files := $(foreach m,$(unbundled_build_modules),$(if $(ALL_MODULES.$(m).INSTALLED),,\
972      $(if $(ALL_MODULES.$(m).BUILT),$(ALL_MODULES.$(m).BUILT):$(m)$(suffix $(ALL_MODULES.$(m).BUILT)))\
973      $(if $(ALL_MODULES.$(m).AAR),$(ALL_MODULES.$(m).AAR):$(m).aar)\
974      ))
975  $(call dist-for-goals,apps_only, $(apps_only_dist_built_files))
976
977  ifeq ($(EMMA_INSTRUMENT),true)
978    $(EMMA_META_ZIP) : $(apps_only_installed_files)
979
980    $(call dist-for-goals,apps_only, $(EMMA_META_ZIP))
981  endif
982
983  $(PROGUARD_DICT_ZIP) : $(apps_only_installed_files)
984  $(call dist-for-goals,apps_only, $(PROGUARD_DICT_ZIP))
985
986  $(SYMBOLS_ZIP) : $(apps_only_installed_files)
987  $(call dist-for-goals,apps_only, $(SYMBOLS_ZIP))
988
989.PHONY: apps_only
990apps_only: $(unbundled_build_modules)
991
992droid_targets: apps_only
993
994# Combine the NOTICE files for a apps_only build
995$(eval $(call combine-notice-files, \
996    $(target_notice_file_txt), \
997    $(target_notice_file_html), \
998    "Notices for files for apps:", \
999    $(TARGET_OUT_NOTICE_FILES), \
1000    $(apps_only_installed_files)))
1001
1002
1003else # TARGET_BUILD_APPS
1004  $(call dist-for-goals, droidcore, \
1005    $(INTERNAL_UPDATE_PACKAGE_TARGET) \
1006    $(INTERNAL_OTA_PACKAGE_TARGET) \
1007    $(BUILT_OTATOOLS_PACKAGE) \
1008    $(SYMBOLS_ZIP) \
1009    $(INSTALLED_FILES_FILE) \
1010    $(INSTALLED_FILES_FILE_VENDOR) \
1011    $(INSTALLED_FILES_FILE_SYSTEMOTHER) \
1012    $(INSTALLED_BUILD_PROP_TARGET) \
1013    $(BUILT_TARGET_FILES_PACKAGE) \
1014    $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
1015    $(INSTALLED_RAMDISK_TARGET) \
1016   )
1017
1018  # Put a copy of the radio/bootloader files in the dist dir.
1019  $(foreach f,$(INSTALLED_RADIOIMAGE_TARGET), \
1020    $(call dist-for-goals, droidcore, $(f)))
1021
1022  ifneq ($(ANDROID_BUILD_EMBEDDED),true)
1023  ifneq ($(TARGET_BUILD_PDK),true)
1024    $(call dist-for-goals, droidcore, \
1025      $(APPS_ZIP) \
1026      $(INTERNAL_EMULATOR_PACKAGE_TARGET) \
1027      $(PACKAGE_STATS_FILE) \
1028    )
1029  endif
1030  endif
1031
1032  ifeq ($(EMMA_INSTRUMENT),true)
1033    $(EMMA_META_ZIP) : $(INSTALLED_SYSTEMIMAGE)
1034
1035    $(call dist-for-goals, dist_files, $(EMMA_META_ZIP))
1036  endif
1037
1038# Building a full system-- the default is to build droidcore
1039droid_targets: droidcore dist_files
1040
1041endif # TARGET_BUILD_APPS
1042
1043.PHONY: docs
1044docs: $(ALL_DOCS)
1045
1046.PHONY: sdk
1047ALL_SDK_TARGETS := $(INTERNAL_SDK_TARGET)
1048sdk: $(ALL_SDK_TARGETS)
1049$(call dist-for-goals,sdk win_sdk, \
1050    $(ALL_SDK_TARGETS) \
1051    $(SYMBOLS_ZIP) \
1052    $(INSTALLED_BUILD_PROP_TARGET) \
1053)
1054
1055# umbrella targets to assit engineers in verifying builds
1056.PHONY: java native target host java-host java-target native-host native-target \
1057        java-host-tests java-target-tests native-host-tests native-target-tests \
1058        java-tests native-tests host-tests target-tests tests
1059# some synonyms
1060.PHONY: host-java target-java host-native target-native \
1061        target-java-tests target-native-tests
1062host-java : java-host
1063target-java : java-target
1064host-native : native-host
1065target-native : native-target
1066target-java-tests : java-target-tests
1067target-native-tests : native-target-tests
1068tests : host-tests target-tests
1069
1070# Phony target to run all java compilations that use javac instead of jack.
1071.PHONY: javac-check
1072
1073# To catch more build breakage, check build tests modules in eng and userdebug builds.
1074ifneq ($(ANDROID_NO_TEST_CHECK),true)
1075ifneq ($(TARGET_BUILD_PDK),true)
1076ifneq ($(filter eng userdebug,$(TARGET_BUILD_VARIANT)),)
1077droidcore : target-tests host-tests
1078endif
1079endif
1080endif
1081
1082ifneq (,$(filter samplecode, $(MAKECMDGOALS)))
1083.PHONY: samplecode
1084sample_MODULES := $(sort $(call get-tagged-modules,samples))
1085sample_APKS_DEST_PATH := $(TARGET_COMMON_OUT_ROOT)/samples
1086sample_APKS_COLLECTION := \
1087        $(foreach module,$(sample_MODULES),$(sample_APKS_DEST_PATH)/$(notdir $(module)))
1088$(foreach module,$(sample_MODULES),$(eval $(call \
1089        copy-one-file,$(module),$(sample_APKS_DEST_PATH)/$(notdir $(module)))))
1090sample_ADDITIONAL_INSTALLED := \
1091        $(filter-out $(modules_to_install) $(modules_to_check),$(sample_MODULES))
1092samplecode: $(sample_APKS_COLLECTION)
1093	@echo "Collect sample code apks: $^"
1094	# remove apks that are not intended to be installed.
1095	rm -f $(sample_ADDITIONAL_INSTALLED)
1096endif  # samplecode in $(MAKECMDGOALS)
1097
1098.PHONY: findbugs
1099findbugs: $(INTERNAL_FINDBUGS_HTML_TARGET) $(INTERNAL_FINDBUGS_XML_TARGET)
1100
1101.PHONY: clean
1102clean:
1103	@rm -rf $(OUT_DIR)/*
1104	@echo "Entire build directory removed."
1105
1106.PHONY: clobber
1107clobber: clean
1108
1109# The rules for dataclean and installclean are defined in cleanbuild.mk.
1110
1111#xxx scrape this from ALL_MODULE_NAME_TAGS
1112.PHONY: modules
1113modules:
1114	@echo "Available sub-modules:"
1115	@echo "$(call module-names-for-tag-list,$(ALL_MODULE_TAGS))" | \
1116	      tr -s ' ' '\n' | sort -u | $(COLUMN)
1117
1118.PHONY: showcommands
1119showcommands:
1120	@echo >/dev/null
1121
1122.PHONY: nothing
1123nothing:
1124	@echo Successfully read the makefiles.
1125
1126.PHONY: tidy_only
1127tidy_only:
1128	@echo Successfully make tidy_only.
1129
1130endif # KATI
1131