blob: 511d19e32d29a81229a12a28bd78eb3520a4003a [file] [log] [blame]
Ying Wang6714dbc2010-03-30 16:42:15 -07001# Only use ANDROID_BUILD_SHELL to wrap around bash.
2# DO NOT use other shells such as zsh.
Ying Wang2ce495a2010-03-30 12:55:13 -07003ifdef ANDROID_BUILD_SHELL
4SHELL := $(ANDROID_BUILD_SHELL)
5else
The Android Open Source Project88b60792009-03-03 19:28:42 -08006# 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
Ying Wang2ce495a2010-03-30 12:55:13 -070010endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080011
12# this turns off the suffix rules built into make
13.SUFFIXES:
14
David 'Digit' Turner52d697d2011-06-22 23:18:57 +020015# this turns off the RCS / SCCS implicit rules of GNU Make
16% : RCS/%,v
17% : RCS/%
18% : %,v
19% : s.%
20% : SCCS/s.%
21
The Android Open Source Project88b60792009-03-03 19:28:42 -080022# If a rule fails, delete $@.
23.DELETE_ON_ERROR:
24
25# Figure out where we are.
26#TOP := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
27#TOP := $(patsubst %/,%,$(TOP))
28
29# TOPDIR is the normal variable you should use, because
30# if we are executing relative to the current directory
31# it can be "", whereas TOP must be "." which causes
32# pattern matching probles when make strips off the
33# trailing "./" from paths in various places.
34#ifeq ($(TOP),.)
35#TOPDIR :=
36#else
37#TOPDIR := $(TOP)/
38#endif
39
Raphael76bf62d2011-12-19 13:37:55 -080040# Check for broken versions of make.
41# (Allow any version under Cygwin since we don't actually build the platform there.)
42ifeq (,$(findstring CYGWIN,$(shell uname -sm)))
synergydev2b537262013-10-16 10:36:32 -070043ifneq (1,$(strip $(shell expr $(MAKE_VERSION) \>= 3.81)))
The Android Open Source Project88b60792009-03-03 19:28:42 -080044$(warning ********************************************************************************)
45$(warning * You are using version $(MAKE_VERSION) of make.)
synergydev2b537262013-10-16 10:36:32 -070046$(warning * Android can only be built by versions 3.81 and higher.)
Jean-Baptiste Queru5d4bcb42012-04-19 14:53:27 -070047$(warning * see https://source.android.com/source/download.html)
The Android Open Source Project88b60792009-03-03 19:28:42 -080048$(warning ********************************************************************************)
49$(error stopping)
50endif
Raphael76bf62d2011-12-19 13:37:55 -080051endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080052
Ying Wang9ccacd72012-05-22 18:29:02 -070053# Absolute path of the present working direcotry.
54# This overrides the shell variable $PWD, which does not necessarily points to
55# the top of the source tree, for example when "make -C" is used in m/mm/mmm.
56PWD := $(shell pwd)
57
The Android Open Source Project88b60792009-03-03 19:28:42 -080058TOP := .
59TOPDIR :=
60
61BUILD_SYSTEM := $(TOPDIR)build/core
62
63# This is the default target. It must be the first declared target.
Joe Onoratoda12daf2010-06-09 18:18:31 -070064.PHONY: droid
The Android Open Source Project88b60792009-03-03 19:28:42 -080065DEFAULT_GOAL := droid
66$(DEFAULT_GOAL):
67
Joe Onorato77dc0a52010-05-17 18:16:11 -070068# Used to force goals to build. Only use for conditionally defined goals.
69.PHONY: FORCE
70FORCE:
71
Ying Wangad7fd292013-08-08 16:34:29 -070072# 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 vendorimage-nodeps \
81 ramdisk-nodeps \
82 bootimage-nodeps
83
84ifneq ($(filter $(dont_bother_goals), $(MAKECMDGOALS)),)
85dont_bother := true
86endif
87
Daniel Sandler95661222010-10-28 15:31:47 -040088# Targets that provide quick help on the build system.
89include $(BUILD_SYSTEM)/help.mk
90
The Android Open Source Project88b60792009-03-03 19:28:42 -080091# Set up various standard variables based on configuration
92# and host information.
93include $(BUILD_SYSTEM)/config.mk
94
Ying Wang50e52fa2013-02-22 18:15:29 -080095# This allows us to force a clean build - included after the config.mk
The Android Open Source Project88b60792009-03-03 19:28:42 -080096# environment setup is done, but before we generate any dependencies. This
97# file does the rm -rf inline so the deps which are all done below will
98# be generated correctly
99include $(BUILD_SYSTEM)/cleanbuild.mk
100
Ying Wang63d94fa2012-12-13 18:23:01 -0800101# Include the google-specific config
102-include vendor/google/build/config.mk
103
Joe Onoratoe35a4452012-07-25 17:55:03 -0700104VERSION_CHECK_SEQUENCE_NUMBER := 3
Joe Onorato1de66882009-07-30 11:54:27 -0700105-include $(OUT_DIR)/versions_checked.mk
106ifneq ($(VERSION_CHECK_SEQUENCE_NUMBER),$(VERSIONS_CHECKED))
107
108$(info Checking build tools versions...)
109
The Android Open Source Project88b60792009-03-03 19:28:42 -0800110ifneq ($(HOST_OS),windows)
111ifneq ($(HOST_OS)-$(HOST_ARCH),darwin-ppc)
112# check for a case sensitive file system
113ifneq (a,$(shell mkdir -p $(OUT_DIR) ; \
114 echo a > $(OUT_DIR)/casecheck.txt; \
115 echo B > $(OUT_DIR)/CaseCheck.txt; \
116 cat $(OUT_DIR)/casecheck.txt))
117$(warning ************************************************************)
118$(warning You are building on a case-insensitive filesystem.)
119$(warning Please move your source tree to a case-sensitive filesystem.)
120$(warning ************************************************************)
121$(error Case-insensitive filesystems not supported)
122endif
123endif
124endif
125
126# Make sure that there are no spaces in the absolute path; the
127# build system can't deal with them.
128ifneq ($(words $(shell pwd)),1)
129$(warning ************************************************************)
130$(warning You are building in a directory whose absolute path contains)
131$(warning a space character:)
132$(warning $(space))
133$(warning "$(shell pwd)")
134$(warning $(space))
135$(warning Please move your source tree to a path that does not contain)
136$(warning any spaces.)
137$(warning ************************************************************)
138$(error Directory names containing spaces not supported)
139endif
140
Ying Wangad690992013-09-20 17:11:43 -0700141# Check for the current jdk
142ifneq ($(EXPERIMENTAL_USE_JAVA7_OPENJDK),)
143# The user asked for java7 openjdk, so check that the host
144# java version is really openjdk
145ifeq ($(shell java -version 2>&1 | grep -i openjdk),)
146$(info ************************************************************)
147$(info You asked for an OpenJDK 7 build but your version is)
148$(info $(shell java -version 2>&1 | head -n 2).)
149$(info ************************************************************)
150$(error stop)
151endif # java version is not OpenJdk
152else # if EXPERIMENTAL_USE_JAVA7_OPENJDK
Tim Roes304f5192013-02-23 20:25:00 +0100153ifneq ($(shell java -version 2>&1 | grep -i openjdk),)
154$(info ************************************************************)
155$(info You are attempting to build with an unsupported JDK.)
156$(info $(space))
157$(info You use OpenJDK but only Sun/Oracle JDK is supported.)
158$(info Please follow the machine setup instructions at)
159$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
160$(info ************************************************************)
161$(error stop)
Ying Wangad690992013-09-20 17:11:43 -0700162endif # java version is not Sun Oracle JDK
163endif # if EXPERIMENTAL_USE_JAVA7_OPENJDK
Joe Onorato9d9f3672009-06-22 18:15:38 -0700164
Ying Wangad690992013-09-20 17:11:43 -0700165# Check for the correct version of java, should be 1.7 if
166# EXPERIMENTAL_USE_JAVA7_OPENJDK is set, 1.6 otherwise.
167ifneq ($(EXPERIMENTAL_USE_JAVA7_OPENJDK),)
168required_version := "OpenJDK 1.7"
169required_javac_version := "1.7"
170java_version := $(shell java -version 2>&1 | head -n 1 | grep '^java .*[ "]1\.7[\. "$$]')
171javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1\.7[\. "$$]')
172else # if EXPERIMENTAL_USE_JAVA7_OPENJDK
173required_version := "JavaSE 1.6"
174required_javac_version := "1.6"
Jean-Baptiste Querud7d096d2010-10-08 10:58:38 -0700175java_version := $(shell java -version 2>&1 | head -n 1 | grep '^java .*[ "]1\.6[\. "$$]')
Ying Wangad690992013-09-20 17:11:43 -0700176javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1\.6[\. "$$]')
177endif # if EXPERIMENTAL_USE_JAVA7_OPENJDK
178
Joe Onorato9d9f3672009-06-22 18:15:38 -0700179ifeq ($(strip $(java_version)),)
180$(info ************************************************************)
181$(info You are attempting to build with the incorrect version)
182$(info of java.)
183$(info $(space))
184$(info Your version is: $(shell java -version 2>&1 | head -n 1).)
Ying Wangad690992013-09-20 17:11:43 -0700185$(info The required version is: $(required_version))
Joe Onorato9d9f3672009-06-22 18:15:38 -0700186$(info $(space))
187$(info Please follow the machine setup instructions at)
Jean-Baptiste Queru5d4bcb42012-04-19 14:53:27 -0700188$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
Joe Onorato9d9f3672009-06-22 18:15:38 -0700189$(info ************************************************************)
Jeff Hamilton4a1c70e2010-06-21 18:26:38 -0500190$(error stop)
Joe Onorato9d9f3672009-06-22 18:15:38 -0700191endif
192
193# Check for the correct version of javac
Joe Onorato9d9f3672009-06-22 18:15:38 -0700194ifeq ($(strip $(javac_version)),)
195$(info ************************************************************)
196$(info You are attempting to build with the incorrect version)
197$(info of javac.)
198$(info $(space))
199$(info Your version is: $(shell javac -version 2>&1 | head -n 1).)
Ying Wangad690992013-09-20 17:11:43 -0700200$(info The required version is: $(required_javac_version))
Joe Onorato9d9f3672009-06-22 18:15:38 -0700201$(info $(space))
202$(info Please follow the machine setup instructions at)
Jean-Baptiste Queru5d4bcb42012-04-19 14:53:27 -0700203$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
Joe Onorato9d9f3672009-06-22 18:15:38 -0700204$(info ************************************************************)
Jeff Hamilton4a1c70e2010-06-21 18:26:38 -0500205$(error stop)
Joe Onorato9d9f3672009-06-22 18:15:38 -0700206endif
207
Ying Wangb036e952013-04-12 14:14:36 -0700208ifndef BUILD_EMULATOR
Ying Wang478ba5e2012-06-28 16:02:19 -0700209ifeq (darwin,$(HOST_OS))
Andrew Hsieh1dcca612012-11-09 02:06:33 -0800210GCC_REALPATH = $(realpath $(shell which $(HOST_CC)))
Ying Wang478ba5e2012-06-28 16:02:19 -0700211ifneq ($(findstring llvm-gcc,$(GCC_REALPATH)),)
212 # Using LLVM GCC results in a non functional emulator due to it
213 # not honouring global register variables
Joe Onoratoe35a4452012-07-25 17:55:03 -0700214 $(warning ****************************************)
215 $(warning * gcc is linked to llvm-gcc which will *)
216 $(warning * not create a useable emulator. *)
217 $(warning ****************************************)
Joe Onorato74e883d2012-07-25 14:28:05 -0700218 BUILD_EMULATOR := false
219else
220 BUILD_EMULATOR := true
221endif
Ying Wang7d8c5352012-07-26 10:15:21 -0700222else # HOST_OS is not darwin
223 BUILD_EMULATOR := true
224endif # HOST_OS is darwin
Ying Wangb036e952013-04-12 14:14:36 -0700225endif
Ying Wang478ba5e2012-06-28 16:02:19 -0700226
Joe Onorato1de66882009-07-30 11:54:27 -0700227$(shell echo 'VERSIONS_CHECKED := $(VERSION_CHECK_SEQUENCE_NUMBER)' \
228 > $(OUT_DIR)/versions_checked.mk)
Ying Wangb036e952013-04-12 14:14:36 -0700229$(shell echo 'BUILD_EMULATOR ?= $(BUILD_EMULATOR)' \
Joe Onoratoe35a4452012-07-25 17:55:03 -0700230 >> $(OUT_DIR)/versions_checked.mk)
Joe Onorato1de66882009-07-30 11:54:27 -0700231endif
232
The Android Open Source Project88b60792009-03-03 19:28:42 -0800233# These are the modifier targets that don't do anything themselves, but
234# change the behavior of the build.
235# (must be defined before including definitions.make)
Ying Wang31268312013-02-21 18:41:51 -0800236INTERNAL_MODIFIER_TARGETS := showcommands all incrementaljavac
Ying Wang015edd22011-01-20 15:01:56 -0800237
238.PHONY: incrementaljavac
239incrementaljavac: ;
240
241# WARNING:
242# ENABLE_INCREMENTALJAVAC should NOT be enabled by default, because change of
243# a Java source file won't trigger rebuild of its dependent Java files.
244# You can only enable it by adding "incrementaljavac" to your make command line.
245# You are responsible for the correctness of the incremental build.
246# This may decrease incremental build time dramatically for large Java libraries,
247# such as core.jar, framework.jar, etc.
248ENABLE_INCREMENTALJAVAC :=
249ifneq (,$(filter incrementaljavac, $(MAKECMDGOALS)))
250ENABLE_INCREMENTALJAVAC := true
251MAKECMDGOALS := $(filter-out incrementaljavac, $(MAKECMDGOALS))
252endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800253
Ying Wangaf4800c2012-08-21 16:59:01 -0700254# EMMA_INSTRUMENT_STATIC merges the static emma library to each emma-enabled module.
255ifeq (true,$(EMMA_INSTRUMENT_STATIC))
256EMMA_INSTRUMENT := true
257endif
258
The Android Open Source Project88b60792009-03-03 19:28:42 -0800259# Bring in standard build system definitions.
260include $(BUILD_SYSTEM)/definitions.mk
261
Ying Wange7874c42010-09-17 16:36:06 -0700262# Bring in dex_preopt.mk
263include $(BUILD_SYSTEM)/dex_preopt.mk
264
Joe Onorato6a185e42012-05-22 14:08:50 -0700265ifneq ($(filter user userdebug eng,$(MAKECMDGOALS)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800266$(info ***************************************************************)
267$(info ***************************************************************)
Ying Wangd0244b32011-11-17 14:51:12 -0800268$(info Do not pass '$(filter user userdebug eng,$(MAKECMDGOALS))' on \
269 the make command line.)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800270$(info Set TARGET_BUILD_VARIANT in buildspec.mk, or use lunch or)
271$(info choosecombo.)
272$(info ***************************************************************)
273$(info ***************************************************************)
274$(error stopping)
275endif
276
The Android Open Source Project2f312932009-03-09 11:52:11 -0700277ifneq ($(filter-out $(INTERNAL_VALID_VARIANTS),$(TARGET_BUILD_VARIANT)),)
278$(info ***************************************************************)
279$(info ***************************************************************)
280$(info Invalid variant: $(TARGET_BUILD_VARIANT)
281$(info Valid values are: $(INTERNAL_VALID_VARIANTS)
282$(info ***************************************************************)
283$(info ***************************************************************)
284$(error stopping)
285endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800286
Keun young Park7fc7aad2012-02-27 15:49:23 -0800287# -----------------------------------------------------------------
Keun young Parkefe02ce2012-06-06 17:19:29 -0700288# Variable to check java support level inside PDK build.
289# Not necessary if the components is not in PDK.
290# not defined : not supported
291# "sdk" : sdk API only
292# "platform" : platform API supproted
293TARGET_BUILD_JAVA_SUPPORT_LEVEL := platform
294
295# -----------------------------------------------------------------
Keun young Park7fc7aad2012-02-27 15:49:23 -0800296# The pdk (Platform Development Kit) build
Ying Wang82b836f2012-03-30 18:08:07 -0700297include build/core/pdk_config.mk
Keun young Park7fc7aad2012-02-27 15:49:23 -0800298
Keun young Park7fc7aad2012-02-27 15:49:23 -0800299# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800300###
301### In this section we set up the things that are different
302### between the build variants
303###
304
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700305is_sdk_build :=
Raphaelc4d47312011-02-15 16:09:36 -0800306
307ifneq ($(filter sdk win_sdk sdk_addon,$(MAKECMDGOALS)),)
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700308is_sdk_build := true
309endif
310
The Android Open Source Project88b60792009-03-03 19:28:42 -0800311## user/userdebug ##
312
Joe Onorato6a185e42012-05-22 14:08:50 -0700313user_variant := $(filter user userdebug,$(TARGET_BUILD_VARIANT))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800314enable_target_debugging := true
Joe Onorato6a185e42012-05-22 14:08:50 -0700315tags_to_install :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800316ifneq (,$(user_variant))
317 # Target is secure in user builds.
318 ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=1
319
The Android Open Source Project88b60792009-03-03 19:28:42 -0800320 ifeq ($(user_variant),userdebug)
321 # Pick up some extra useful tools
The Android Open Source Project2f312932009-03-09 11:52:11 -0700322 tags_to_install += debug
Brad Fitzpatrick135677a2010-04-16 16:55:41 -0700323
324 # Enable Dalvik lock contention logging for userdebug builds.
325 ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.lockprof.threshold=500
The Android Open Source Project88b60792009-03-03 19:28:42 -0800326 else
327 # Disable debugging in plain user builds.
328 enable_target_debugging :=
329 endif
Dan Bornsteinf13bdd92010-09-07 17:45:44 -0700330
Dan Bornsteinf7ad63a2011-05-31 10:29:47 -0700331 # Turn on Dalvik preoptimization for user builds, but only if not
332 # explicitly disabled and the build is running on Linux (since host
333 # Dalvik isn't built for non-Linux hosts).
Ying Wang02352372010-09-27 10:37:25 -0700334 ifneq (true,$(DISABLE_DEXPREOPT))
Dan Bornsteinf7ad63a2011-05-31 10:29:47 -0700335 ifeq ($(user_variant),user)
336 ifeq ($(HOST_OS),linux)
337 WITH_DEXPREOPT := true
338 endif
339 endif
Ying Wang02352372010-09-27 10:37:25 -0700340 endif
Dan Bornsteinf13bdd92010-09-07 17:45:44 -0700341
The Android Open Source Project88b60792009-03-03 19:28:42 -0800342 # Disallow mock locations by default for user builds
343 ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=0
Dan Bornsteinf13bdd92010-09-07 17:45:44 -0700344
The Android Open Source Project88b60792009-03-03 19:28:42 -0800345else # !user_variant
346 # Turn on checkjni for non-user builds.
347 ADDITIONAL_BUILD_PROPERTIES += ro.kernel.android.checkjni=1
348 # Set device insecure for non-user builds.
349 ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0
350 # Allow mock locations by default for non user builds
351 ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=1
352endif # !user_variant
353
354ifeq (true,$(strip $(enable_target_debugging)))
355 # Target is more debuggable and adbd is on by default
Mike Lockwood40b5a672011-07-01 12:31:47 -0400356 ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1
The Android Open Source Project88b60792009-03-03 19:28:42 -0800357 # Include the debugging/testing OTA keys in this build.
358 INCLUDE_TEST_OTA_KEYS := true
359else # !enable_target_debugging
360 # Target is less debuggable and adbd is off by default
Mike Lockwood40b5a672011-07-01 12:31:47 -0400361 ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0
The Android Open Source Project88b60792009-03-03 19:28:42 -0800362endif # !enable_target_debugging
363
The Android Open Source Project2f312932009-03-09 11:52:11 -0700364## eng ##
365
366ifeq ($(TARGET_BUILD_VARIANT),eng)
Joe Onorato6a185e42012-05-22 14:08:50 -0700367tags_to_install := debug eng
Bruce Beareb056d712011-12-01 12:46:12 -0800368ifneq ($(filter ro.setupwizard.mode=ENABLED, $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))),)
The Android Open Source Projectfdd3a102009-03-11 12:11:54 -0700369 # Don't require the setup wizard on eng builds
370 ADDITIONAL_BUILD_PROPERTIES := $(filter-out ro.setupwizard.mode=%,\
Joe Onorato08896612009-10-07 10:01:13 -0700371 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))) \
372 ro.setupwizard.mode=OPTIONAL
The Android Open Source Project2f312932009-03-09 11:52:11 -0700373endif
Bruce Beareb056d712011-12-01 12:46:12 -0800374endif
The Android Open Source Project2f312932009-03-09 11:52:11 -0700375
The Android Open Source Project88b60792009-03-03 19:28:42 -0800376## sdk ##
377
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700378ifdef is_sdk_build
Raphaelc4d47312011-02-15 16:09:36 -0800379
380# Detect if we want to build a repository for the SDK
381sdk_repo_goal := $(strip $(filter sdk_repo,$(MAKECMDGOALS)))
382MAKECMDGOALS := $(strip $(filter-out sdk_repo,$(MAKECMDGOALS)))
383
Ying Wangfcec57a2013-06-26 17:56:08 -0700384ifneq ($(words $(filter-out $(INTERNAL_MODIFIER_TARGETS) checkbuild,$(MAKECMDGOALS))),1)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800385$(error The 'sdk' target may not be specified with any other targets)
386endif
Raphael3d224a02010-04-16 17:50:09 -0700387
The Android Open Source Project2f312932009-03-09 11:52:11 -0700388# TODO: this should be eng I think. Since the sdk is built from the eng
389# variant.
Joe Onorato6a185e42012-05-22 14:08:50 -0700390tags_to_install := debug eng
The Android Open Source Project88b60792009-03-03 19:28:42 -0800391ADDITIONAL_BUILD_PROPERTIES += xmpp.auto-presence=true
392ADDITIONAL_BUILD_PROPERTIES += ro.config.nocheckin=yes
393else # !sdk
The Android Open Source Project88b60792009-03-03 19:28:42 -0800394endif
395
Andreas Huber200f2592010-08-30 12:48:03 -0700396BUILD_WITHOUT_PV := true
397
Andy McFadden743e2502009-04-13 14:48:35 -0700398## precise GC ##
399
400ifneq ($(filter dalvik.gc.type-precise,$(PRODUCT_TAGS)),)
401 # Enabling type-precise GC results in larger optimized DEX files. The
402 # additional storage requirements for ".odex" files can cause /system
403 # to overflow on some devices, so this is configured separately for
404 # each product.
405 ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.dexopt-flags=m=y
406endif
407
The Android Open Source Project88b60792009-03-03 19:28:42 -0800408ADDITIONAL_BUILD_PROPERTIES += net.bt.name=Android
409
410# enable vm tracing in files for now to help track
411# the cause of ANRs in the content process
412ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.stack-trace-file=/data/anr/traces.txt
413
The Android Open Source Project88b60792009-03-03 19:28:42 -0800414# ------------------------------------------------------------
415# Define a function that, given a list of module tags, returns
416# non-empty if that module should be installed in /system.
417
The Android Open Source Project2f312932009-03-09 11:52:11 -0700418# For most goals, anything not tagged with the "tests" tag should
The Android Open Source Project88b60792009-03-03 19:28:42 -0800419# be installed in /system.
420define should-install-to-system
The Android Open Source Project2f312932009-03-09 11:52:11 -0700421$(if $(filter tests,$(1)),,true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800422endef
423
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700424ifdef is_sdk_build
The Android Open Source Project88b60792009-03-03 19:28:42 -0800425# For the sdk goal, anything with the "samples" tag should be
426# installed in /data even if that module also has "eng"/"debug"/"user".
427define should-install-to-system
The Android Open Source Project2f312932009-03-09 11:52:11 -0700428$(if $(filter samples tests,$(1)),,true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800429endef
430endif
431
432
Ying Wang31268312013-02-21 18:41:51 -0800433# If they only used the modifier goals (showcommands, etc), we'll actually
Joe Onoratoe334d252009-07-17 15:33:40 -0400434# build the default target.
435ifeq ($(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS)),)
436.PHONY: $(INTERNAL_MODIFIER_TARGETS)
437$(INTERNAL_MODIFIER_TARGETS): $(DEFAULT_GOAL)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800438endif
439
The Android Open Source Project88b60792009-03-03 19:28:42 -0800440# Bring in all modules that need to be built.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800441ifeq ($(HOST_OS)-$(HOST_ARCH),darwin-ppc)
442SDK_ONLY := true
Raphael Moll7058f492010-04-13 10:38:35 -0700443$(info Building the SDK under darwin-ppc is actually obsolete and unsupported.)
444$(error stop)
445endif
446
447ifeq ($(HOST_OS),windows)
448SDK_ONLY := true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800449endif
450
451ifeq ($(SDK_ONLY),true)
Raphael Moll8a2b7702013-03-13 15:30:35 -0700452include $(TOPDIR)sdk/build/windows_sdk_whitelist.mk
453include $(TOPDIR)development/build/windows_sdk_whitelist.mk
The Android Open Source Project88b60792009-03-03 19:28:42 -0800454
455# Exclude tools/acp when cross-compiling windows under linux
456ifeq ($(findstring Linux,$(UNAME)),)
457subdirs += build/tools/acp
458endif
459
460else # !SDK_ONLY
The Android Open Source Project88b60792009-03-03 19:28:42 -0800461#
462# Typical build; include any Android.mk files we can find.
463#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800464subdirs := $(TOP)
465
466FULL_BUILD := true
467
The Android Open Source Project88b60792009-03-03 19:28:42 -0800468endif # !SDK_ONLY
469
Joe Onorato8dc8faa2010-09-14 13:09:48 -0400470# Before we go and include all of the module makefiles, stash away
Ying Wang7522f042010-10-11 16:31:49 -0700471# the PRODUCT_* values so that later we can verify they are not modified.
472stash_product_vars:=true
Joe Onorato8dc8faa2010-09-14 13:09:48 -0400473ifeq ($(stash_product_vars),true)
Ying Wang7522f042010-10-11 16:31:49 -0700474 $(call stash-product-vars, __STASHED)
Joe Onorato8dc8faa2010-09-14 13:09:48 -0400475endif
476
The Android Open Source Project88b60792009-03-03 19:28:42 -0800477ifneq ($(ONE_SHOT_MAKEFILE),)
478# We've probably been invoked by the "mm" shell function
479# with a subdirectory's makefile.
480include $(ONE_SHOT_MAKEFILE)
481# Change CUSTOM_MODULES to include only modules that were
482# defined by this makefile; this will install all of those
483# modules as a side-effect. Do this after including ONE_SHOT_MAKEFILE
484# so that the modules will be installed in the same place they
485# would have been with a normal make.
Jean-Baptiste Queru6907cfe2010-01-07 11:19:39 -0800486CUSTOM_MODULES := $(sort $(call get-tagged-modules,$(ALL_MODULE_TAGS)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800487FULL_BUILD :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800488# Stub out the notice targets, which probably aren't defined
489# when using ONE_SHOT_MAKEFILE.
490NOTICE-HOST-%: ;
491NOTICE-TARGET-%: ;
Joe Onoratoead96462009-07-30 11:20:04 -0700492
Ying Wanga7deb082013-08-16 13:24:47 -0700493# A helper goal printing out install paths
494.PHONY: GET-INSTALL-PATH
495GET-INSTALL-PATH:
496 @$(foreach m, $(ALL_MODULES), $(if $(ALL_MODULES.$(m).INSTALLED), \
497 echo 'INSTALL-PATH: $(m) $(ALL_MODULES.$(m).INSTALLED)';))
498
Joe Onoratoead96462009-07-30 11:20:04 -0700499else # ONE_SHOT_MAKEFILE
500
Ying Wang20ef3542013-09-09 12:11:02 -0700501ifneq ($(dont_bother),true)
Joe Onoratoead96462009-07-30 11:20:04 -0700502#
503# Include all of the makefiles in the system
504#
505
506# Can't use first-makefiles-under here because
507# --mindepth=2 makes the prunes not work.
508subdir_makefiles := \
JP Abgrall1390cac2013-07-11 19:08:06 -0700509 $(shell build/tools/findleaves.py --prune=$(OUT_DIR) --prune=.repo --prune=.git $(subdirs) Android.mk)
Joe Onoratoead96462009-07-30 11:20:04 -0700510
Ying Wang172f5f52013-07-31 12:18:36 -0700511$(foreach mk, $(subdir_makefiles), $(info including $(mk) ...)$(eval include $(mk)))
Ying Wang71004f82012-05-24 21:05:19 -0700512
Ying Wang20ef3542013-09-09 12:11:02 -0700513endif # dont_bother
The Android Open Source Project88b60792009-03-03 19:28:42 -0800514
Joe Onoratoead96462009-07-30 11:20:04 -0700515endif # ONE_SHOT_MAKEFILE
516
Ying Wang71004f82012-05-24 21:05:19 -0700517# Now with all Android.mks loaded we can do post cleaning steps.
518include $(BUILD_SYSTEM)/post_clean.mk
519
Joe Onorato8dc8faa2010-09-14 13:09:48 -0400520ifeq ($(stash_product_vars),true)
Ying Wang7522f042010-10-11 16:31:49 -0700521 $(call assert-product-vars, __STASHED)
Joe Onorato8dc8faa2010-09-14 13:09:48 -0400522endif
523
Jean-Baptiste Queru09447712010-09-26 13:05:41 -0700524include $(BUILD_SYSTEM)/legacy_prebuilts.mk
525ifneq ($(filter-out $(GRANDFATHERED_ALL_PREBUILT),$(strip $(notdir $(ALL_PREBUILT)))),)
526 $(warning *** Some files have been added to ALL_PREBUILT.)
527 $(warning *)
Kenny Root824d7b22010-11-18 14:27:00 -0800528 $(warning * ALL_PREBUILT is a deprecated mechanism that)
Jean-Baptiste Queru09447712010-09-26 13:05:41 -0700529 $(warning * should not be used for new files.)
530 $(warning * As an alternative, use PRODUCT_COPY_FILES in)
531 $(warning * the appropriate product definition.)
532 $(warning * build/target/product/core.mk is the product)
533 $(warning * definition used in all products.)
534 $(warning *)
535 $(foreach bad_prebuilt,$(filter-out $(GRANDFATHERED_ALL_PREBUILT),$(strip $(notdir $(ALL_PREBUILT)))),$(warning * unexpected $(bad_prebuilt) in ALL_PREBUILT))
536 $(warning *)
537 $(error ALL_PREBUILT contains unexpected files)
538endif
539
The Android Open Source Project88b60792009-03-03 19:28:42 -0800540# -------------------------------------------------------------------
541# All module makefiles have been included at this point.
542# -------------------------------------------------------------------
543
The Android Open Source Project88b60792009-03-03 19:28:42 -0800544
545# -------------------------------------------------------------------
546# Fix up CUSTOM_MODULES to refer to installed files rather than
547# just bare module names. Leave unknown modules alone in case
548# they're actually full paths to a particular file.
549known_custom_modules := $(filter $(ALL_MODULES),$(CUSTOM_MODULES))
550unknown_custom_modules := $(filter-out $(ALL_MODULES),$(CUSTOM_MODULES))
551CUSTOM_MODULES := \
552 $(call module-installed-files,$(known_custom_modules)) \
553 $(unknown_custom_modules)
554
555# -------------------------------------------------------------------
556# Define dependencies for modules that require other modules.
557# This can only happen now, after we've read in all module makefiles.
558#
559# TODO: deal with the fact that a bare module name isn't
560# unambiguous enough. Maybe declare short targets like
561# APPS:Quake or HOST:SHARED_LIBRARIES:libutils.
562# BUG: the system image won't know to depend on modules that are
563# brought in as requirements of other modules.
564define add-required-deps
Ying Wang9485a572013-02-22 14:32:30 -0800565$(1): | $(2)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800566endef
567$(foreach m,$(ALL_MODULES), \
568 $(eval r := $(ALL_MODULES.$(m).REQUIRED)) \
569 $(if $(r), \
570 $(eval r := $(call module-installed-files,$(r))) \
Ying Wang16b92ed2013-06-06 18:05:53 -0700571 $(eval t_m := $(filter $(TARGET_OUT_ROOT)/%, $(ALL_MODULES.$(m).INSTALLED))) \
572 $(eval h_m := $(filter $(HOST_OUT_ROOT)/%, $(ALL_MODULES.$(m).INSTALLED))) \
573 $(eval t_r := $(filter $(TARGET_OUT_ROOT)/%, $(r))) \
574 $(eval h_r := $(filter $(HOST_OUT_ROOT)/%, $(r))) \
575 $(if $(t_m), $(eval $(call add-required-deps, $(t_m),$(t_r)))) \
576 $(if $(h_m), $(eval $(call add-required-deps, $(h_m),$(h_r)))) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800577 ) \
578 )
Ying Wang9485a572013-02-22 14:32:30 -0800579
Ying Wang16b92ed2013-06-06 18:05:53 -0700580t_m :=
581h_m :=
582t_r :=
583h_r :=
584
Ying Wang9485a572013-02-22 14:32:30 -0800585# Resolve the dependencies on shared libraries.
586$(foreach m,$(TARGET_DEPENDENCIES_ON_SHARED_LIBRARIES), \
587 $(eval p := $(subst :,$(space),$(m))) \
588 $(eval r := $(filter $(TARGET_OUT_ROOT)/%,$(call module-installed-files,\
589 $(subst $(comma),$(space),$(lastword $(p)))))) \
Ying Wangd6b1d612013-04-15 17:32:21 -0700590 $(eval $(call add-required-deps,$(word 2,$(p)),$(r))))
Ying Wang9485a572013-02-22 14:32:30 -0800591$(foreach m,$(HOST_DEPENDENCIES_ON_SHARED_LIBRARIES), \
592 $(eval p := $(subst :,$(space),$(m))) \
593 $(eval r := $(filter $(HOST_OUT_ROOT)/%,$(call module-installed-files,\
594 $(subst $(comma),$(space),$(lastword $(p)))))) \
Ying Wangd6b1d612013-04-15 17:32:21 -0700595 $(eval $(call add-required-deps,$(word 2,$(p)),$(r))))
Ying Wang9485a572013-02-22 14:32:30 -0800596
The Android Open Source Project88b60792009-03-03 19:28:42 -0800597m :=
598r :=
Ying Wang9485a572013-02-22 14:32:30 -0800599p :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800600add-required-deps :=
601
602# -------------------------------------------------------------------
603# Figure out our module sets.
Joe Onorato6a185e42012-05-22 14:08:50 -0700604#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800605# Of the modules defined by the component makefiles,
606# determine what we actually want to build.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800607
608ifdef FULL_BUILD
609 # The base list of modules to build for this product is specified
610 # by the appropriate product definition file, which was included
611 # by product_config.make.
Joe Onorato8d0847e2012-07-11 19:38:48 -0700612 product_MODULES := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES)
Ying Wang489458f2012-08-23 15:08:34 -0700613 # Filter out the overridden packages before doing expansion
614 product_MODULES := $(filter-out $(foreach p, $(product_MODULES), \
615 $(PACKAGES.$(p).OVERRIDES)), $(product_MODULES))
Joe Onorato8d0847e2012-07-11 19:38:48 -0700616 $(call expand-required-modules,product_MODULES,$(product_MODULES))
617 product_FILES := $(call module-installed-files, $(product_MODULES))
Joe Onorato6a185e42012-05-22 14:08:50 -0700618 ifeq (0,1)
Joe Onorato8d0847e2012-07-11 19:38:48 -0700619 $(info product_FILES for $(TARGET_DEVICE) ($(INTERNAL_PRODUCT)):)
620 $(foreach p,$(product_FILES),$(info : $(p)))
Joe Onorato6a185e42012-05-22 14:08:50 -0700621 $(error done)
622 endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800623else
624 # We're not doing a full build, and are probably only including
625 # a subset of the module makefiles. Don't try to build any modules
626 # requested by the product, because we probably won't have rules
627 # to build them.
Joe Onorato8d0847e2012-07-11 19:38:48 -0700628 product_FILES :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800629endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800630
Joe Onoratod7d0afc2012-06-05 15:54:09 -0700631eng_MODULES := $(sort \
632 $(call get-tagged-modules,eng) \
633 $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_ENG)) \
634 )
635debug_MODULES := $(sort \
636 $(call get-tagged-modules,debug) \
637 $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_DEBUG)) \
638 )
639tests_MODULES := $(sort \
640 $(call get-tagged-modules,tests) \
641 $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_TESTS)) \
642 )
The Android Open Source Project88b60792009-03-03 19:28:42 -0800643
Joe Onorato6a185e42012-05-22 14:08:50 -0700644# TODO: Remove the 3 places in the tree that use ALL_DEFAULT_INSTALLED_MODULES
645# and get rid of it from this list.
Joe Onorato6a185e42012-05-22 14:08:50 -0700646modules_to_install := $(sort \
Joe Onoratoe2139442012-05-22 17:33:22 -0700647 $(ALL_DEFAULT_INSTALLED_MODULES) \
Joe Onorato8d0847e2012-07-11 19:38:48 -0700648 $(product_FILES) \
Joe Onoratoe2139442012-05-22 17:33:22 -0700649 $(foreach tag,$(tags_to_install),$($(tag)_MODULES)) \
Joe Onoratoe2139442012-05-22 17:33:22 -0700650 $(CUSTOM_MODULES) \
651 )
The Android Open Source Project88b60792009-03-03 19:28:42 -0800652
653# Some packages may override others using LOCAL_OVERRIDES_PACKAGES.
654# Filter out (do not install) any overridden packages.
The Android Open Source Project2f312932009-03-09 11:52:11 -0700655overridden_packages := $(call get-package-overrides,$(modules_to_install))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800656ifdef overridden_packages
The Android Open Source Project2f312932009-03-09 11:52:11 -0700657# old_modules_to_install := $(modules_to_install)
658 modules_to_install := \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800659 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \
The Android Open Source Project2f312932009-03-09 11:52:11 -0700660 $(modules_to_install))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800661endif
The Android Open Source Project2f312932009-03-09 11:52:11 -0700662#$(error filtered out
663# $(filter-out $(modules_to_install),$(old_modules_to_install)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800664
665# Don't include any GNU targets in the SDK. It's ok (and necessary)
666# to build the host tools, but nothing that's going to be installed
667# on the target (including static libraries).
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700668ifdef is_sdk_build
The Android Open Source Project88b60792009-03-03 19:28:42 -0800669 target_gnu_MODULES := \
670 $(filter \
671 $(TARGET_OUT_INTERMEDIATES)/% \
672 $(TARGET_OUT)/% \
673 $(TARGET_OUT_DATA)/%, \
674 $(sort $(call get-tagged-modules,gnu)))
675 $(info Removing from sdk:)$(foreach d,$(target_gnu_MODULES),$(info : $(d)))
The Android Open Source Project2f312932009-03-09 11:52:11 -0700676 modules_to_install := \
677 $(filter-out $(target_gnu_MODULES),$(modules_to_install))
Ying Wang486be822011-10-08 14:31:54 -0700678
Joe Onoratod7d0afc2012-06-05 15:54:09 -0700679 # Ensure every module listed in PRODUCT_PACKAGES* gets something installed
680 # TODO: Should we do this for all builds and not just the sdk?
Ying Wang486be822011-10-08 14:31:54 -0700681 $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES), \
Joe Onoratocea08a52012-08-17 00:09:27 -0700682 $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\
Ying Wang92cd50c2012-10-31 11:55:53 -0700683 $(error $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES has nothing to install!)))
Joe Onoratod7d0afc2012-06-05 15:54:09 -0700684 $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_DEBUG), \
Joe Onoratocea08a52012-08-17 00:09:27 -0700685 $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\
Joe Onoratoc5fbef52012-08-17 01:26:41 -0700686 $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_DEBUG has nothing to install!)))
Joe Onoratod7d0afc2012-06-05 15:54:09 -0700687 $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_ENG), \
Joe Onoratocea08a52012-08-17 00:09:27 -0700688 $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\
Joe Onoratoc5fbef52012-08-17 01:26:41 -0700689 $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_ENG has nothing to install!)))
Joe Onoratod7d0afc2012-06-05 15:54:09 -0700690 $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_TESTS), \
Joe Onoratocea08a52012-08-17 00:09:27 -0700691 $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\
Joe Onoratoc5fbef52012-08-17 01:26:41 -0700692 $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_TESTS has nothing to install!)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800693endif
694
Joe Onoratoe334d252009-07-17 15:33:40 -0400695# build/core/Makefile contains extra stuff that we don't want to pollute this
The Android Open Source Project88b60792009-03-03 19:28:42 -0800696# top-level makefile with. It expects that ALL_DEFAULT_INSTALLED_MODULES
697# contains everything that's built during the current make, but it also further
698# extends ALL_DEFAULT_INSTALLED_MODULES.
The Android Open Source Project2f312932009-03-09 11:52:11 -0700699ALL_DEFAULT_INSTALLED_MODULES := $(modules_to_install)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800700include $(BUILD_SYSTEM)/Makefile
The Android Open Source Project2f312932009-03-09 11:52:11 -0700701modules_to_install := $(sort $(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800702ALL_DEFAULT_INSTALLED_MODULES :=
703
Joe Onoratof93f5be2012-05-21 12:16:05 -0700704
Joe Onoratoe334d252009-07-17 15:33:40 -0400705# These are additional goals that we build, in order to make sure that there
706# is as little code as possible in the tree that doesn't build.
707modules_to_check := $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).CHECKED))
708
709# If you would like to build all goals, and not skip any intermediate
710# steps, you can pass the "all" modifier goal on the commandline.
711ifneq ($(filter all,$(MAKECMDGOALS)),)
712modules_to_check += $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).BUILT))
713endif
714
715# for easier debugging
716modules_to_check := $(sort $(modules_to_check))
717#$(error modules_to_check $(modules_to_check))
718
The Android Open Source Project88b60792009-03-03 19:28:42 -0800719# -------------------------------------------------------------------
720# This is used to to get the ordering right, you can also use these,
721# but they're considered undocumented, so don't complain if their
722# behavior changes.
723.PHONY: prebuilt
724prebuilt: $(ALL_PREBUILT)
725
726# An internal target that depends on all copied headers
727# (see copy_headers.make). Other targets that need the
728# headers to be copied first can depend on this target.
729.PHONY: all_copied_headers
730all_copied_headers: ;
731
732$(ALL_C_CPP_ETC_OBJECTS): | all_copied_headers
733
734# All the droid stuff, in directories
735.PHONY: files
Joe Onoratoe334d252009-07-17 15:33:40 -0400736files: prebuilt \
737 $(modules_to_install) \
Joe Onoratoe334d252009-07-17 15:33:40 -0400738 $(INSTALLED_ANDROID_INFO_TXT_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800739
740# -------------------------------------------------------------------
741
Joe Onoratoe334d252009-07-17 15:33:40 -0400742.PHONY: checkbuild
743checkbuild: $(modules_to_check)
Ying Wang31268312013-02-21 18:41:51 -0800744ifeq (true,$(ANDROID_BUILD_EVERYTHING_BY_DEFAULT)$(filter $(MAKECMDGOALS),checkbuild))
745droid: checkbuild
746else
747# ANDROID_BUILD_EVERYTHING_BY_DEFAULT not set, or checkbuild is one of the cmd goals.
748checkbuild: droid
749endif
Joe Onoratoe334d252009-07-17 15:33:40 -0400750
The Android Open Source Project88b60792009-03-03 19:28:42 -0800751.PHONY: ramdisk
752ramdisk: $(INSTALLED_RAMDISK_TARGET)
753
Ying Wang89686532011-12-16 11:27:52 -0800754.PHONY: factory_ramdisk
755factory_ramdisk: $(INSTALLED_FACTORY_RAMDISK_TARGET)
756
Joe Onoratoe1d191e2012-05-17 11:32:26 -0700757.PHONY: factory_bundle
758factory_bundle: $(INSTALLED_FACTORY_BUNDLE_TARGET)
759
The Android Open Source Project88b60792009-03-03 19:28:42 -0800760.PHONY: systemtarball
761systemtarball: $(INSTALLED_SYSTEMTARBALL_TARGET)
762
Bruce Beare52aac202010-06-04 15:24:49 -0700763.PHONY: boottarball
764boottarball: $(INSTALLED_BOOTTARBALL_TARGET)
765
The Android Open Source Project88b60792009-03-03 19:28:42 -0800766.PHONY: userdataimage
767userdataimage: $(INSTALLED_USERDATAIMAGE_TARGET)
768
Ying Wang9c0f3e32011-02-01 14:52:05 -0800769ifneq (,$(filter userdataimage, $(MAKECMDGOALS)))
770$(call dist-for-goals, userdataimage, $(BUILT_USERDATAIMAGE_TARGET))
771endif
772
The Android Open Source Project88b60792009-03-03 19:28:42 -0800773.PHONY: userdatatarball
774userdatatarball: $(INSTALLED_USERDATATARBALL_TARGET)
775
Ying Wang9f8e8db2011-11-04 11:37:01 -0700776.PHONY: cacheimage
777cacheimage: $(INSTALLED_CACHEIMAGE_TARGET)
778
Ying Wanga0febe52013-03-20 11:02:05 -0700779.PHONY: vendorimage
780vendorimage: $(INSTALLED_VENDORIMAGE_TARGET)
781
The Android Open Source Project88b60792009-03-03 19:28:42 -0800782.PHONY: bootimage
783bootimage: $(INSTALLED_BOOTIMAGE_TARGET)
784
Ying Wangb607f7b2013-02-08 18:01:04 -0800785# phony target that include any targets in $(ALL_MODULES)
786.PHONY: all_modules
787ifndef BUILD_MODULES_IN_PATHS
788all_modules: $(ALL_MODULES)
789else
790# BUILD_MODULES_IN_PATHS is a list of paths relative to the top of the tree
791module_path_patterns := $(foreach p, $(BUILD_MODULES_IN_PATHS),\
792 $(if $(filter %/,$(p)),$(p)%,$(p)/%))
793my_all_modules := $(sort $(foreach m, $(ALL_MODULES),$(if $(filter\
794 $(module_path_patterns), $(addsuffix /,$(ALL_MODULES.$(m).PATH))),$(m))))
795all_modules: $(my_all_modules)
796endif
797
798
The Android Open Source Project88b60792009-03-03 19:28:42 -0800799# Build files and then package it into the rom formats
800.PHONY: droidcore
801droidcore: files \
802 systemimage \
803 $(INSTALLED_BOOTIMAGE_TARGET) \
804 $(INSTALLED_RECOVERYIMAGE_TARGET) \
805 $(INSTALLED_USERDATAIMAGE_TARGET) \
Ying Wang9f8e8db2011-11-04 11:37:01 -0700806 $(INSTALLED_CACHEIMAGE_TARGET) \
Ying Wanga0febe52013-03-20 11:02:05 -0700807 $(INSTALLED_VENDORIMAGE_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800808 $(INSTALLED_FILES_FILE)
809
Ying Wang228fcef2010-12-08 20:07:48 -0800810# dist_files only for putting your library into the dist directory with a full build.
811.PHONY: dist_files
Ying Wangad8aec92010-07-13 21:08:38 -0700812
Joe Onorato16fa4b22010-06-09 16:35:58 -0700813ifneq ($(TARGET_BUILD_APPS),)
Joe Onoratoda12daf2010-06-09 18:18:31 -0700814 # If this build is just for apps, only build apps and not the full system by default.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800815
Joe Onorato16fa4b22010-06-09 16:35:58 -0700816 unbundled_build_modules :=
817 ifneq ($(filter all,$(TARGET_BUILD_APPS)),)
Ying Wangc048c9b2010-06-24 15:08:33 -0700818 # If they used the magic goal "all" then build all apps in the source tree.
819 unbundled_build_modules := $(foreach m,$(sort $(ALL_MODULES)),$(if $(filter APPS,$(ALL_MODULES.$(m).CLASS)),$(m)))
Joe Onorato16fa4b22010-06-09 16:35:58 -0700820 else
821 unbundled_build_modules := $(TARGET_BUILD_APPS)
822 endif
Guang Zhu0198d6e2010-04-23 11:54:37 -0700823
Ying Wang1e1241c2013-06-12 15:25:23 -0700824 # Dist the installed files if they exist.
Ying Wangda19eaf2012-08-15 12:22:44 -0700825 apps_only_installed_files := $(foreach m,$(unbundled_build_modules),$(ALL_MODULES.$(m).INSTALLED))
Ying Wangda19eaf2012-08-15 12:22:44 -0700826 $(call dist-for-goals,apps_only, $(apps_only_installed_files))
Ying Wang1e1241c2013-06-12 15:25:23 -0700827 # For uninstallable modules such as static Java library, we have to dist the built file,
828 # as <module_name>.<suffix>
829 apps_only_dist_built_files := $(foreach m,$(unbundled_build_modules),$(if $(ALL_MODULES.$(m).INSTALLED),,\
Ying Wang495f6842013-08-27 15:04:57 -0700830 $(if $(ALL_MODULES.$(m).BUILT),$(ALL_MODULES.$(m).BUILT):$(m)$(suffix $(ALL_MODULES.$(m).BUILT)))))
Ying Wang1e1241c2013-06-12 15:25:23 -0700831 $(call dist-for-goals,apps_only, $(apps_only_dist_built_files))
Ying Wangda19eaf2012-08-15 12:22:44 -0700832
833 ifeq ($(EMMA_INSTRUMENT),true)
834 $(EMMA_META_ZIP) : $(apps_only_installed_files)
835
836 $(call dist-for-goals,apps_only, $(EMMA_META_ZIP))
837 endif
Joe Onorato16fa4b22010-06-09 16:35:58 -0700838
Ying Wangae9115a2013-08-22 20:52:47 -0700839 $(PROGUARD_DICT_ZIP) : $(apps_only_installed_files)
840 $(call dist-for-goals,apps_only, $(PROGUARD_DICT_ZIP))
841
Joe Onoratoda12daf2010-06-09 18:18:31 -0700842.PHONY: apps_only
843apps_only: $(unbundled_build_modules)
Joe Onorato16fa4b22010-06-09 16:35:58 -0700844
Joe Onoratoda12daf2010-06-09 18:18:31 -0700845droid: apps_only
846
Ying Wang62c81f82013-08-22 20:02:03 -0700847# Combine the NOTICE files for a apps_only build
848$(eval $(call combine-notice-files, \
849 $(target_notice_file_txt), \
850 $(target_notice_file_html), \
851 "Notices for files for apps:", \
852 $(TARGET_OUT_NOTICE_FILES), \
853 $(apps_only_installed_files)))
854
855
Joe Onoratoda12daf2010-06-09 18:18:31 -0700856else # TARGET_BUILD_APPS
857 $(call dist-for-goals, droidcore, \
Joe Onorato16fa4b22010-06-09 16:35:58 -0700858 $(INTERNAL_UPDATE_PACKAGE_TARGET) \
859 $(INTERNAL_OTA_PACKAGE_TARGET) \
860 $(SYMBOLS_ZIP) \
Joe Onorato16fa4b22010-06-09 16:35:58 -0700861 $(INSTALLED_FILES_FILE) \
862 $(INSTALLED_BUILD_PROP_TARGET) \
863 $(BUILT_TARGET_FILES_PACKAGE) \
864 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
Ed Heyl8532aa02010-07-01 10:07:28 -0700865 $(INSTALLED_RAMDISK_TARGET) \
Ying Wang89686532011-12-16 11:27:52 -0800866 $(INSTALLED_FACTORY_RAMDISK_TARGET) \
Joe Onoratoe1d191e2012-05-17 11:32:26 -0700867 $(INSTALLED_FACTORY_BUNDLE_TARGET) \
Joe Onorato16fa4b22010-06-09 16:35:58 -0700868 )
869
Ying Wang94de1eb2013-07-26 12:19:20 -0700870 # Put a copy of the radio/bootloader files in the dist dir.
871 $(foreach f,$(INSTALLED_RADIOIMAGE_TARGET), \
872 $(call dist-for-goals, droidcore, $(f)))
873
Colin Cross971c2462012-03-29 14:31:08 -0700874 ifneq ($(TARGET_BUILD_PDK),true)
875 $(call dist-for-goals, droidcore, \
876 $(APPS_ZIP) \
877 $(INTERNAL_EMULATOR_PACKAGE_TARGET) \
878 $(PACKAGE_STATS_FILE) \
879 )
880 endif
881
Ying Wangda19eaf2012-08-15 12:22:44 -0700882 ifeq ($(EMMA_INSTRUMENT),true)
883 $(EMMA_META_ZIP) : $(INSTALLED_SYSTEMIMAGE)
884
885 $(call dist-for-goals, dist_files, $(EMMA_META_ZIP))
886 endif
887
Joe Onoratoda12daf2010-06-09 18:18:31 -0700888# Building a full system-- the default is to build droidcore
Ying Wang228fcef2010-12-08 20:07:48 -0800889droid: droidcore dist_files
Joe Onoratoda12daf2010-06-09 18:18:31 -0700890
Ying Wangf9cd36a2010-06-15 15:43:13 -0700891endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -0800892
893.PHONY: docs
894docs: $(ALL_DOCS)
895
896.PHONY: sdk
897ALL_SDK_TARGETS := $(INTERNAL_SDK_TARGET)
898sdk: $(ALL_SDK_TARGETS)
Raphaelc4d47312011-02-15 16:09:36 -0800899$(call dist-for-goals,sdk win_sdk, \
Ying Wangbe188ca2011-03-07 16:13:32 -0800900 $(ALL_SDK_TARGETS) \
901 $(SYMBOLS_ZIP) \
902 $(INSTALLED_BUILD_PROP_TARGET) \
903)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800904
Ying Wangef4d82f2013-01-29 16:59:18 -0800905# umbrella targets to assit engineers in verifying builds
Ying Wang1d977e32013-01-30 11:22:06 -0800906.PHONY: java native target host java-host java-target native-host native-target \
Ying Wangef4d82f2013-01-29 16:59:18 -0800907 java-host-tests java-target-tests native-host-tests native-target-tests \
908 java-tests native-tests host-tests target-tests
909# some synonyms
910.PHONY: host-java target-java host-native target-native \
911 target-java-tests target-native-tests
912host-java : java-host
913target-java : java-target
914host-native : native-host
915target-native : native-target
916target-java-tests : java-target-tests
917target-native-tests : native-target-tests
918
919
Ying Wang0d570a72012-06-18 18:45:40 -0700920.PHONY: lintall
921
Ying Wang8b9b39e2010-02-25 20:20:43 -0800922.PHONY: samplecode
923sample_MODULES := $(sort $(call get-tagged-modules,samples))
924sample_APKS_DEST_PATH := $(TARGET_COMMON_OUT_ROOT)/samples
925sample_APKS_COLLECTION := \
926 $(foreach module,$(sample_MODULES),$(sample_APKS_DEST_PATH)/$(notdir $(module)))
927$(foreach module,$(sample_MODULES),$(eval $(call \
928 copy-one-file,$(module),$(sample_APKS_DEST_PATH)/$(notdir $(module)))))
929sample_ADDITIONAL_INSTALLED := \
930 $(filter-out $(modules_to_install) $(modules_to_check) $(ALL_PREBUILT),$(sample_MODULES))
931samplecode: $(sample_APKS_COLLECTION)
932 @echo "Collect sample code apks: $^"
933 # remove apks that are not intended to be installed.
934 rm -f $(sample_ADDITIONAL_INSTALLED)
935
The Android Open Source Project88b60792009-03-03 19:28:42 -0800936.PHONY: findbugs
937findbugs: $(INTERNAL_FINDBUGS_HTML_TARGET) $(INTERNAL_FINDBUGS_XML_TARGET)
938
939.PHONY: clean
The Android Open Source Project88b60792009-03-03 19:28:42 -0800940clean:
The Android Open Source Project88b60792009-03-03 19:28:42 -0800941 @rm -rf $(OUT_DIR)
942 @echo "Entire build directory removed."
943
Joe Onoratodfc5e0c2010-09-03 13:25:11 -0400944.PHONY: clobber
945clobber: clean
946
The Android Open Source Project88b60792009-03-03 19:28:42 -0800947# The rules for dataclean and installclean are defined in cleanbuild.mk.
948
949#xxx scrape this from ALL_MODULE_NAME_TAGS
950.PHONY: modules
951modules:
952 @echo "Available sub-modules:"
953 @echo "$(call module-names-for-tag-list,$(ALL_MODULE_TAGS))" | \
Evan JIANGf3806922009-01-24 00:11:30 +0800954 tr -s ' ' '\n' | sort -u | $(COLUMN)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800955
956.PHONY: showcommands
957showcommands:
958 @echo >/dev/null
Joe Onorato10649c62012-05-18 20:41:38 -0700959
960.PHONY: nothing
961nothing:
962 @echo Successfully read the makefiles.