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