main.mk revision d2ff15715976bcb0179518565de134508236b5c2
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    vbmetaimage-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# AUX dependencies are already added by now; remove triggers from the MAKECMDGOALS
457MAKECMDGOALS := $(strip $(filter-out AUX-%,$(MAKECMDGOALS)))
458
459# TODO: this should be eng I think.  Since the sdk is built from the eng
460# variant.
461tags_to_install := debug eng
462ADDITIONAL_BUILD_PROPERTIES += xmpp.auto-presence=true
463ADDITIONAL_BUILD_PROPERTIES += ro.config.nocheckin=yes
464else # !sdk
465endif
466
467BUILD_WITHOUT_PV := true
468
469ADDITIONAL_BUILD_PROPERTIES += net.bt.name=Android
470
471# enable vm tracing in files for now to help track
472# the cause of ANRs in the content process
473ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.stack-trace-file=/data/anr/traces.txt
474
475# ------------------------------------------------------------
476# Define a function that, given a list of module tags, returns
477# non-empty if that module should be installed in /system.
478
479# For most goals, anything not tagged with the "tests" tag should
480# be installed in /system.
481define should-install-to-system
482$(if $(filter tests,$(1)),,true)
483endef
484
485ifdef is_sdk_build
486# For the sdk goal, anything with the "samples" tag should be
487# installed in /data even if that module also has "eng"/"debug"/"user".
488define should-install-to-system
489$(if $(filter samples tests,$(1)),,true)
490endef
491endif
492
493
494# If they only used the modifier goals (showcommands, etc), we'll actually
495# build the default target.
496ifeq ($(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS)),)
497.PHONY: $(INTERNAL_MODIFIER_TARGETS)
498$(INTERNAL_MODIFIER_TARGETS): $(DEFAULT_GOAL)
499endif
500
501#
502# Typical build; include any Android.mk files we can find.
503#
504
505FULL_BUILD := true
506
507# Before we go and include all of the module makefiles, stash away
508# the PRODUCT_* values so that later we can verify they are not modified.
509stash_product_vars:=true
510ifeq ($(stash_product_vars),true)
511  $(call stash-product-vars, __STASHED)
512endif
513
514ifneq ($(ONE_SHOT_MAKEFILE),)
515# We've probably been invoked by the "mm" shell function
516# with a subdirectory's makefile.
517include $(SOONG_ANDROID_MK) $(wildcard $(ONE_SHOT_MAKEFILE))
518# Change CUSTOM_MODULES to include only modules that were
519# defined by this makefile; this will install all of those
520# modules as a side-effect.  Do this after including ONE_SHOT_MAKEFILE
521# so that the modules will be installed in the same place they
522# would have been with a normal make.
523CUSTOM_MODULES := $(sort $(call get-tagged-modules,$(ALL_MODULE_TAGS)))
524FULL_BUILD :=
525# Stub out the notice targets, which probably aren't defined
526# when using ONE_SHOT_MAKEFILE.
527NOTICE-HOST-%: ;
528NOTICE-TARGET-%: ;
529
530# A helper goal printing out install paths
531define register_module_install_path
532.PHONY: GET-MODULE-INSTALL-PATH-$(1)
533GET-MODULE-INSTALL-PATH-$(1):
534	echo 'INSTALL-PATH: $(1) $(ALL_MODULES.$(1).INSTALLED)'
535endef
536
537SORTED_ALL_MODULES := $(sort $(ALL_MODULES))
538UNIQUE_ALL_MODULES :=
539$(foreach m,$(SORTED_ALL_MODULES),\
540    $(if $(call streq,$(m),$(lastword $(UNIQUE_ALL_MODULES))),,\
541        $(eval UNIQUE_ALL_MODULES += $(m))))
542SORTED_ALL_MODULES :=
543
544$(foreach mod,$(UNIQUE_ALL_MODULES),$(if $(ALL_MODULES.$(mod).INSTALLED),\
545    $(eval $(call register_module_install_path,$(mod)))\
546    $(foreach path,$(ALL_MODULES.$(mod).PATH),\
547        $(eval my_path_prefix := GET-INSTALL-PATH-IN)\
548        $(foreach component,$(subst /,$(space),$(path)),\
549            $(eval my_path_prefix := $$(my_path_prefix)-$$(component))\
550            $(eval .PHONY: $$(my_path_prefix))\
551            $(eval $$(my_path_prefix): GET-MODULE-INSTALL-PATH-$(mod))))))
552UNIQUE_ALL_MODULES :=
553
554else # ONE_SHOT_MAKEFILE
555
556ifneq ($(dont_bother),true)
557#
558# Include all of the makefiles in the system
559#
560
561subdir_makefiles := $(SOONG_ANDROID_MK) $(call first-makefiles-under,$(TOP))
562
563$(foreach mk,$(subdir_makefiles),$(info including $(mk) ...)$(eval include $(mk)))
564
565ifdef PDK_FUSION_PLATFORM_ZIP
566# Bring in the PDK platform.zip modules.
567include $(BUILD_SYSTEM)/pdk_fusion_modules.mk
568endif # PDK_FUSION_PLATFORM_ZIP
569
570endif # dont_bother
571
572endif # ONE_SHOT_MAKEFILE
573
574# Now with all Android.mks loaded we can do post cleaning steps.
575include $(BUILD_SYSTEM)/post_clean.mk
576
577ifeq ($(stash_product_vars),true)
578  $(call assert-product-vars, __STASHED)
579endif
580
581# -------------------------------------------------------------------
582# All module makefiles have been included at this point.
583# -------------------------------------------------------------------
584
585
586# -------------------------------------------------------------------
587# Fix up CUSTOM_MODULES to refer to installed files rather than
588# just bare module names.  Leave unknown modules alone in case
589# they're actually full paths to a particular file.
590known_custom_modules := $(filter $(ALL_MODULES),$(CUSTOM_MODULES))
591unknown_custom_modules := $(filter-out $(ALL_MODULES),$(CUSTOM_MODULES))
592CUSTOM_MODULES := \
593	$(call module-installed-files,$(known_custom_modules)) \
594	$(unknown_custom_modules)
595
596# -------------------------------------------------------------------
597# Define dependencies for modules that require other modules.
598# This can only happen now, after we've read in all module makefiles.
599#
600# TODO: deal with the fact that a bare module name isn't
601# unambiguous enough.  Maybe declare short targets like
602# APPS:Quake or HOST:SHARED_LIBRARIES:libutils.
603# BUG: the system image won't know to depend on modules that are
604# brought in as requirements of other modules.
605#
606# Resolve the required module name to 32-bit or 64-bit variant.
607# Get a list of corresponding 32-bit module names, if one exists.
608ifneq ($(TARGET_TRANSLATE_2ND_ARCH),true)
609define get-32-bit-modules
610$(sort $(foreach m,$(1),\
611  $(if $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).CLASS),\
612    $(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX))\
613  $(if $(ALL_MODULES.$(m)$(HOST_2ND_ARCH_MODULE_SUFFIX).CLASS),\
614    $(m)$(HOST_2ND_ARCH_MODULE_SUFFIX))\
615    ))
616endef
617# Get a list of corresponding 32-bit module names, if one exists;
618# otherwise return the original module name
619define get-32-bit-modules-if-we-can
620$(sort $(foreach m,$(1),\
621  $(if $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).CLASS)$(ALL_MODULES.$(m)$(HOST_2ND_ARCH_MODULE_SUFFIX).CLASS),\
622    $(if $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).CLASS),$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX)) \
623    $(if $(ALL_MODULES.$(m)$(HOST_2ND_ARCH_MODULE_SUFFIX).CLASS),$(m)$(HOST_2ND_ARCH_MODULE_SUFFIX)),\
624  $(m))))
625endef
626else  # TARGET_TRANSLATE_2ND_ARCH
627# For binary translation config, by default only install the first arch.
628define get-32-bit-modules
629endef
630
631define get-32-bit-modules-if-we-can
632$(strip $(1))
633endef
634endif  # TARGET_TRANSLATE_2ND_ARCH
635
636# If a module is for a cross host os, the required modules must be for
637# that OS too.
638# If a module is built for 32-bit, the required modules must be 32-bit too;
639# Otherwise if the module is an exectuable or shared library,
640#   the required modules must be 64-bit;
641#   otherwise we require both 64-bit and 32-bit variant, if one exists.
642$(foreach m,$(ALL_MODULES),\
643  $(eval r := $(ALL_MODULES.$(m).REQUIRED))\
644  $(if $(r),\
645    $(if $(ALL_MODULES.$(m).FOR_HOST_CROSS),\
646      $(eval r := $(addprefix host_cross_,$(r))))\
647    $(if $(ALL_MODULES.$(m).FOR_2ND_ARCH),\
648      $(eval r_r := $(call get-32-bit-modules-if-we-can,$(r))),\
649      $(if $(filter EXECUTABLES SHARED_LIBRARIES NATIVE_TESTS,$(ALL_MODULES.$(m).CLASS)),\
650        $(eval r_r := $(r)),\
651        $(eval r_r := $(r) $(call get-32-bit-modules,$(r)))\
652       )\
653     )\
654     $(eval ALL_MODULES.$(m).REQUIRED := $(strip $(r_r)))\
655  )\
656)
657r_r :=
658
659define add-required-deps
660$(1): | $(2)
661endef
662
663# Use a normal dependency instead of an order-only dependency when installing
664# host dynamic binaries so that the timestamp of the final binary always
665# changes, even if the toc optimization has skipped relinking the binary
666# and its dependant shared libraries.
667define add-required-host-so-deps
668$(1): $(2)
669endef
670
671$(foreach m,$(ALL_MODULES), \
672  $(eval r := $(ALL_MODULES.$(m).REQUIRED)) \
673  $(if $(r), \
674    $(eval r := $(call module-installed-files,$(r))) \
675    $(eval t_m := $(filter $(TARGET_OUT_ROOT)/%, $(ALL_MODULES.$(m).INSTALLED))) \
676    $(eval h_m := $(filter $(HOST_OUT)/%, $(ALL_MODULES.$(m).INSTALLED))) \
677    $(eval hc_m := $(filter $(HOST_CROSS_OUT)/%, $(ALL_MODULES.$(m).INSTALLED))) \
678    $(eval t_r := $(filter $(TARGET_OUT_ROOT)/%, $(r))) \
679    $(eval h_r := $(filter $(HOST_OUT)/%, $(r))) \
680    $(eval hc_r := $(filter $(HOST_CROSS_OUT)/%, $(r))) \
681    $(eval t_m := $(filter-out $(t_r), $(t_m))) \
682    $(eval h_m := $(filter-out $(h_r), $(h_m))) \
683    $(eval hc_m := $(filter-out $(hc_r), $(hc_m))) \
684    $(if $(t_m), $(eval $(call add-required-deps, $(t_m),$(t_r)))) \
685    $(if $(h_m), $(eval $(call add-required-deps, $(h_m),$(h_r)))) \
686    $(if $(hc_m), $(eval $(call add-required-deps, $(hc_m),$(hc_r)))) \
687   ) \
688 )
689
690t_m :=
691h_m :=
692hc_m :=
693t_r :=
694h_r :=
695hc_r :=
696
697# Establish the dependecies on the shared libraries.
698# It also adds the shared library module names to ALL_MODULES.$(m).REQUIRED,
699# so they can be expanded to product_MODULES later.
700# $(1): TARGET_ or HOST_ or HOST_CROSS_.
701# $(2): non-empty for 2nd arch.
702# $(3): non-empty for host cross compile.
703define resolve-shared-libs-depes
704$(foreach m,$($(if $(2),$($(1)2ND_ARCH_VAR_PREFIX))$(1)DEPENDENCIES_ON_SHARED_LIBRARIES),\
705  $(eval p := $(subst :,$(space),$(m)))\
706  $(eval mod := $(firstword $(p)))\
707  $(eval deps := $(subst $(comma),$(space),$(lastword $(p))))\
708  $(eval root := $(1)OUT$(if $(call streq,$(1),TARGET_),_ROOT))\
709  $(if $(2),$(eval deps := $(addsuffix $($(1)2ND_ARCH_MODULE_SUFFIX),$(deps))))\
710  $(if $(3),$(eval deps := $(addprefix host_cross_,$(deps))))\
711  $(eval r := $(filter $($(root))/%,$(call module-installed-files,\
712    $(deps))))\
713  $(if $(filter $(1),HOST_),\
714    $(eval $(call add-required-host-so-deps,$(word 2,$(p)),$(r))),\
715    $(eval $(call add-required-deps,$(word 2,$(p)),$(r))))\
716  $(eval ALL_MODULES.$(mod).REQUIRED += $(deps)))
717endef
718
719$(call resolve-shared-libs-depes,TARGET_)
720ifdef TARGET_2ND_ARCH
721$(call resolve-shared-libs-depes,TARGET_,true)
722endif
723$(call resolve-shared-libs-depes,HOST_)
724ifdef HOST_2ND_ARCH
725$(call resolve-shared-libs-depes,HOST_,true)
726endif
727ifdef HOST_CROSS_OS
728$(call resolve-shared-libs-depes,HOST_CROSS_,,true)
729endif
730
731m :=
732r :=
733p :=
734deps :=
735add-required-deps :=
736
737# -------------------------------------------------------------------
738# Figure out our module sets.
739#
740# Of the modules defined by the component makefiles,
741# determine what we actually want to build.
742
743###########################################################
744## Expand a module name list with REQUIRED modules
745###########################################################
746# $(1): The variable name that holds the initial module name list.
747#       the variable will be modified to hold the expanded results.
748# $(2): The initial module name list.
749# Returns empty string (maybe with some whitespaces).
750define expand-required-modules
751$(eval _erm_new_modules := $(sort $(filter-out $($(1)),\
752  $(foreach m,$(2),$(ALL_MODULES.$(m).REQUIRED)))))\
753$(if $(_erm_new_modules),$(eval $(1) += $(_erm_new_modules))\
754  $(call expand-required-modules,$(1),$(_erm_new_modules)))
755endef
756
757ifdef FULL_BUILD
758  # The base list of modules to build for this product is specified
759  # by the appropriate product definition file, which was included
760  # by product_config.mk.
761  product_MODULES := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES)
762  # Filter out the overridden packages before doing expansion
763  product_MODULES := $(filter-out $(foreach p, $(product_MODULES), \
764      $(PACKAGES.$(p).OVERRIDES)), $(product_MODULES))
765
766  # Resolve the :32 :64 module name
767  modules_32 := $(patsubst %:32,%,$(filter %:32, $(product_MODULES)))
768  modules_64 := $(patsubst %:64,%,$(filter %:64, $(product_MODULES)))
769  modules_rest := $(filter-out %:32 %:64,$(product_MODULES))
770  # Note for 32-bit product, $(modules_32) and $(modules_64) will be
771  # added as their original module names.
772  product_MODULES := $(call get-32-bit-modules-if-we-can, $(modules_32))
773  product_MODULES += $(modules_64)
774  # For the rest we add both
775  product_MODULES += $(call get-32-bit-modules, $(modules_rest))
776  product_MODULES += $(modules_rest)
777
778  $(call expand-required-modules,product_MODULES,$(product_MODULES))
779
780  product_FILES := $(call module-installed-files, $(product_MODULES))
781  ifeq (0,1)
782    $(info product_FILES for $(TARGET_DEVICE) ($(INTERNAL_PRODUCT)):)
783    $(foreach p,$(product_FILES),$(info :   $(p)))
784    $(error done)
785  endif
786else
787  # We're not doing a full build, and are probably only including
788  # a subset of the module makefiles.  Don't try to build any modules
789  # requested by the product, because we probably won't have rules
790  # to build them.
791  product_FILES :=
792endif
793
794eng_MODULES := $(sort \
795        $(call get-tagged-modules,eng) \
796        $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_ENG)) \
797    )
798debug_MODULES := $(sort \
799        $(call get-tagged-modules,debug) \
800        $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_DEBUG)) \
801    )
802tests_MODULES := $(sort \
803        $(call get-tagged-modules,tests) \
804        $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_TESTS)) \
805    )
806
807# TODO: Remove the 3 places in the tree that use ALL_DEFAULT_INSTALLED_MODULES
808# and get rid of it from this list.
809modules_to_install := $(sort \
810    $(ALL_DEFAULT_INSTALLED_MODULES) \
811    $(product_FILES) \
812    $(foreach tag,$(tags_to_install),$($(tag)_MODULES)) \
813    $(CUSTOM_MODULES) \
814  )
815
816# Some packages may override others using LOCAL_OVERRIDES_PACKAGES.
817# Filter out (do not install) any overridden packages.
818overridden_packages := $(call get-package-overrides,$(modules_to_install))
819ifdef overridden_packages
820#  old_modules_to_install := $(modules_to_install)
821  modules_to_install := \
822      $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk %/$(p).odex), \
823          $(modules_to_install))
824endif
825#$(error filtered out
826#           $(filter-out $(modules_to_install),$(old_modules_to_install)))
827
828# Don't include any GNU General Public License shared objects or static
829# libraries in SDK images.  GPL executables (not static/dynamic libraries)
830# are okay if they don't link against any closed source libraries (directly
831# or indirectly)
832
833# It's ok (and necessary) to build the host tools, but nothing that's
834# going to be installed on the target (including static libraries).
835
836ifdef is_sdk_build
837  target_gnu_MODULES := \
838              $(filter \
839                      $(TARGET_OUT_INTERMEDIATES)/% \
840                      $(TARGET_OUT)/% \
841                      $(TARGET_OUT_DATA)/%, \
842                              $(sort $(call get-tagged-modules,gnu)))
843  target_gnu_MODULES := $(filter-out $(TARGET_OUT_EXECUTABLES)/%,$(target_gnu_MODULES))
844  $(info Removing from sdk:)$(foreach d,$(target_gnu_MODULES),$(info : $(d)))
845  modules_to_install := \
846              $(filter-out $(target_gnu_MODULES),$(modules_to_install))
847
848  # Ensure every module listed in PRODUCT_PACKAGES* gets something installed
849  # TODO: Should we do this for all builds and not just the sdk?
850  dangling_modules :=
851  $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES), \
852    $(if $(strip $(ALL_MODULES.$(m).INSTALLED) $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).INSTALLED)),,\
853      $(eval dangling_modules += $(m))))
854  ifneq ($(dangling_modules),)
855    $(warning: Modules '$(dangling_modules)' in PRODUCT_PACKAGES have nothing to install!)
856  endif
857  $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_DEBUG), \
858    $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\
859      $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_DEBUG has nothing to install!)))
860  $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_ENG), \
861    $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\
862      $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_ENG has nothing to install!)))
863  $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_TESTS), \
864    $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\
865      $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_TESTS has nothing to install!)))
866endif
867
868# build/core/Makefile contains extra stuff that we don't want to pollute this
869# top-level makefile with.  It expects that ALL_DEFAULT_INSTALLED_MODULES
870# contains everything that's built during the current make, but it also further
871# extends ALL_DEFAULT_INSTALLED_MODULES.
872ALL_DEFAULT_INSTALLED_MODULES := $(modules_to_install)
873include $(BUILD_SYSTEM)/Makefile
874modules_to_install := $(sort $(ALL_DEFAULT_INSTALLED_MODULES))
875ALL_DEFAULT_INSTALLED_MODULES :=
876
877
878# These are additional goals that we build, in order to make sure that there
879# is as little code as possible in the tree that doesn't build.
880modules_to_check := $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).CHECKED))
881
882# If you would like to build all goals, and not skip any intermediate
883# steps, you can pass the "all" modifier goal on the commandline.
884ifneq ($(filter all,$(MAKECMDGOALS)),)
885modules_to_check += $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).BUILT))
886endif
887
888# for easier debugging
889modules_to_check := $(sort $(modules_to_check))
890#$(error modules_to_check $(modules_to_check))
891
892# -------------------------------------------------------------------
893# This is used to to get the ordering right, you can also use these,
894# but they're considered undocumented, so don't complain if their
895# behavior changes.
896# An internal target that depends on all copied headers
897# (see copy_headers.make).  Other targets that need the
898# headers to be copied first can depend on this target.
899.PHONY: all_copied_headers
900all_copied_headers: ;
901
902$(ALL_C_CPP_ETC_OBJECTS): | all_copied_headers
903
904# All the droid stuff, in directories
905.PHONY: files
906files: $(modules_to_install) \
907       $(INSTALLED_ANDROID_INFO_TXT_TARGET)
908
909# -------------------------------------------------------------------
910
911.PHONY: checkbuild
912checkbuild: $(modules_to_check) droid_targets
913checkbuild: checkbuild-soong
914
915ifeq (true,$(ANDROID_BUILD_EVERYTHING_BY_DEFAULT))
916droid: checkbuild
917endif
918
919.PHONY: ramdisk
920ramdisk: $(INSTALLED_RAMDISK_TARGET)
921
922.PHONY: systemtarball
923systemtarball: $(INSTALLED_SYSTEMTARBALL_TARGET)
924
925.PHONY: boottarball
926boottarball: $(INSTALLED_BOOTTARBALL_TARGET)
927
928.PHONY: userdataimage
929userdataimage: $(INSTALLED_USERDATAIMAGE_TARGET)
930
931ifneq (,$(filter userdataimage, $(MAKECMDGOALS)))
932$(call dist-for-goals, userdataimage, $(BUILT_USERDATAIMAGE_TARGET))
933endif
934
935.PHONY: userdatatarball
936userdatatarball: $(INSTALLED_USERDATATARBALL_TARGET)
937
938.PHONY: cacheimage
939cacheimage: $(INSTALLED_CACHEIMAGE_TARGET)
940
941.PHONY: bptimage
942bptimage: $(INSTALLED_BPTIMAGE_TARGET)
943
944.PHONY: vendorimage
945vendorimage: $(INSTALLED_VENDORIMAGE_TARGET)
946
947.PHONY: bootimage
948bootimage: $(INSTALLED_BOOTIMAGE_TARGET)
949
950.PHONY: vbmetaimage
951vbmetaimage: $(INSTALLED_VBMETAIMAGE_TARGET)
952
953.PHONY: auxiliary
954auxiliary: $(INSTALLED_AUX_TARGETS)
955
956# Build files and then package it into the rom formats
957.PHONY: droidcore
958droidcore: files \
959	systemimage \
960	$(INSTALLED_BOOTIMAGE_TARGET) \
961	$(INSTALLED_RECOVERYIMAGE_TARGET) \
962	$(INSTALLED_VBMETAIMAGE_TARGET) \
963	$(INSTALLED_USERDATAIMAGE_TARGET) \
964	$(INSTALLED_CACHEIMAGE_TARGET) \
965	$(INSTALLED_BPTIMAGE_TARGET) \
966	$(INSTALLED_VENDORIMAGE_TARGET) \
967	$(INSTALLED_FILES_FILE) \
968	$(INSTALLED_FILES_FILE_VENDOR)
969
970# dist_files only for putting your library into the dist directory with a full build.
971.PHONY: dist_files
972
973ifneq ($(TARGET_BUILD_APPS),)
974  # If this build is just for apps, only build apps and not the full system by default.
975
976  unbundled_build_modules :=
977  ifneq ($(filter all,$(TARGET_BUILD_APPS)),)
978    # If they used the magic goal "all" then build all apps in the source tree.
979    unbundled_build_modules := $(foreach m,$(sort $(ALL_MODULES)),$(if $(filter APPS,$(ALL_MODULES.$(m).CLASS)),$(m)))
980  else
981    unbundled_build_modules := $(TARGET_BUILD_APPS)
982  endif
983
984  # Dist the installed files if they exist.
985  apps_only_installed_files := $(foreach m,$(unbundled_build_modules),$(ALL_MODULES.$(m).INSTALLED))
986  $(call dist-for-goals,apps_only, $(apps_only_installed_files))
987  # For uninstallable modules such as static Java library, we have to dist the built file,
988  # as <module_name>.<suffix>
989  apps_only_dist_built_files := $(foreach m,$(unbundled_build_modules),$(if $(ALL_MODULES.$(m).INSTALLED),,\
990      $(if $(ALL_MODULES.$(m).BUILT),$(ALL_MODULES.$(m).BUILT):$(m)$(suffix $(ALL_MODULES.$(m).BUILT)))\
991      $(if $(ALL_MODULES.$(m).AAR),$(ALL_MODULES.$(m).AAR):$(m).aar)\
992      ))
993  $(call dist-for-goals,apps_only, $(apps_only_dist_built_files))
994
995  ifeq ($(EMMA_INSTRUMENT),true)
996    $(EMMA_META_ZIP) : $(apps_only_installed_files)
997
998    $(call dist-for-goals,apps_only, $(EMMA_META_ZIP))
999  endif
1000
1001  $(PROGUARD_DICT_ZIP) : $(apps_only_installed_files)
1002  $(call dist-for-goals,apps_only, $(PROGUARD_DICT_ZIP))
1003
1004  $(SYMBOLS_ZIP) : $(apps_only_installed_files)
1005  $(call dist-for-goals,apps_only, $(SYMBOLS_ZIP))
1006
1007  $(COVERAGE_ZIP) : $(apps_only_installed_files)
1008  $(call dist-for-goals,apps_only, $(COVERAGE_ZIP))
1009
1010.PHONY: apps_only
1011apps_only: $(unbundled_build_modules)
1012
1013droid_targets: apps_only
1014
1015# Combine the NOTICE files for a apps_only build
1016$(eval $(call combine-notice-files, \
1017    $(target_notice_file_txt), \
1018    $(target_notice_file_html), \
1019    "Notices for files for apps:", \
1020    $(TARGET_OUT_NOTICE_FILES), \
1021    $(apps_only_installed_files)))
1022
1023
1024else # TARGET_BUILD_APPS
1025  $(call dist-for-goals, droidcore, \
1026    $(INTERNAL_UPDATE_PACKAGE_TARGET) \
1027    $(INTERNAL_OTA_PACKAGE_TARGET) \
1028    $(BUILT_OTATOOLS_PACKAGE) \
1029    $(SYMBOLS_ZIP) \
1030    $(COVERAGE_ZIP) \
1031    $(INSTALLED_FILES_FILE) \
1032    $(INSTALLED_FILES_FILE_VENDOR) \
1033    $(INSTALLED_BUILD_PROP_TARGET) \
1034    $(BUILT_TARGET_FILES_PACKAGE) \
1035    $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
1036    $(INSTALLED_RAMDISK_TARGET) \
1037   )
1038
1039  # Put a copy of the radio/bootloader files in the dist dir.
1040  $(foreach f,$(INSTALLED_RADIOIMAGE_TARGET), \
1041    $(call dist-for-goals, droidcore, $(f)))
1042
1043  ifneq ($(ANDROID_BUILD_EMBEDDED),true)
1044  ifneq ($(TARGET_BUILD_PDK),true)
1045    $(call dist-for-goals, droidcore, \
1046      $(APPS_ZIP) \
1047      $(INTERNAL_EMULATOR_PACKAGE_TARGET) \
1048      $(PACKAGE_STATS_FILE) \
1049    )
1050  endif
1051  endif
1052
1053  ifeq ($(EMMA_INSTRUMENT),true)
1054    $(EMMA_META_ZIP) : $(INSTALLED_SYSTEMIMAGE)
1055
1056    $(call dist-for-goals, dist_files, $(EMMA_META_ZIP))
1057  endif
1058
1059# Building a full system-- the default is to build droidcore
1060droid_targets: droidcore dist_files
1061
1062endif # TARGET_BUILD_APPS
1063
1064.PHONY: docs
1065docs: $(ALL_DOCS)
1066
1067.PHONY: sdk
1068ALL_SDK_TARGETS := $(INTERNAL_SDK_TARGET)
1069sdk: $(ALL_SDK_TARGETS)
1070$(call dist-for-goals,sdk win_sdk, \
1071    $(ALL_SDK_TARGETS) \
1072    $(SYMBOLS_ZIP) \
1073    $(COVERAGE_ZIP) \
1074    $(INSTALLED_BUILD_PROP_TARGET) \
1075)
1076
1077# umbrella targets to assit engineers in verifying builds
1078.PHONY: java native target host java-host java-target native-host native-target \
1079        java-host-tests java-target-tests native-host-tests native-target-tests \
1080        java-tests native-tests host-tests target-tests tests
1081# some synonyms
1082.PHONY: host-java target-java host-native target-native \
1083        target-java-tests target-native-tests
1084host-java : java-host
1085target-java : java-target
1086host-native : native-host
1087target-native : native-target
1088target-java-tests : java-target-tests
1089target-native-tests : native-target-tests
1090tests : host-tests target-tests
1091
1092# Phony target to run all java compilations that use javac instead of jack.
1093.PHONY: javac-check
1094
1095# To catch more build breakage, check build tests modules in eng and userdebug builds.
1096ifneq ($(ANDROID_NO_TEST_CHECK),true)
1097ifneq ($(TARGET_BUILD_PDK),true)
1098ifneq ($(filter eng userdebug,$(TARGET_BUILD_VARIANT)),)
1099droidcore : target-tests host-tests
1100endif
1101endif
1102endif
1103
1104ifneq (,$(filter samplecode, $(MAKECMDGOALS)))
1105.PHONY: samplecode
1106sample_MODULES := $(sort $(call get-tagged-modules,samples))
1107sample_APKS_DEST_PATH := $(TARGET_COMMON_OUT_ROOT)/samples
1108sample_APKS_COLLECTION := \
1109        $(foreach module,$(sample_MODULES),$(sample_APKS_DEST_PATH)/$(notdir $(module)))
1110$(foreach module,$(sample_MODULES),$(eval $(call \
1111        copy-one-file,$(module),$(sample_APKS_DEST_PATH)/$(notdir $(module)))))
1112sample_ADDITIONAL_INSTALLED := \
1113        $(filter-out $(modules_to_install) $(modules_to_check),$(sample_MODULES))
1114samplecode: $(sample_APKS_COLLECTION)
1115	@echo "Collect sample code apks: $^"
1116	# remove apks that are not intended to be installed.
1117	rm -f $(sample_ADDITIONAL_INSTALLED)
1118endif  # samplecode in $(MAKECMDGOALS)
1119
1120.PHONY: findbugs
1121findbugs: $(INTERNAL_FINDBUGS_HTML_TARGET) $(INTERNAL_FINDBUGS_XML_TARGET)
1122
1123.PHONY: clean
1124clean:
1125	@rm -rf $(OUT_DIR)/*
1126	@echo "Entire build directory removed."
1127
1128.PHONY: clobber
1129clobber: clean
1130
1131# The rules for dataclean and installclean are defined in cleanbuild.mk.
1132
1133#xxx scrape this from ALL_MODULE_NAME_TAGS
1134.PHONY: modules
1135modules:
1136	@echo "Available sub-modules:"
1137	@echo "$(call module-names-for-tag-list,$(ALL_MODULE_TAGS))" | \
1138	      tr -s ' ' '\n' | sort -u | $(COLUMN)
1139
1140.PHONY: showcommands
1141showcommands:
1142	@echo >/dev/null
1143
1144.PHONY: nothing
1145nothing:
1146	@echo Successfully read the makefiles.
1147
1148.PHONY: tidy_only
1149tidy_only:
1150	@echo Successfully make tidy_only.
1151
1152ndk: $(SOONG_OUT_DIR)/ndk.timestamp
1153.PHONY: ndk
1154
1155.PHONY: all_link_types
1156all_link_types:
1157
1158endif # KATI
1159