blob: cc57ae8ae462167e07f55d11e9c0f9a21873fe36 [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
Narayan Kamathe2d27882013-12-05 12:26:35 +0000141# Check for the current JDK.
142#
143# For Java 1.7, we require OpenJDK on linux and Oracle JDK on Mac OS.
144# For Java 1.6, we require Oracle for all host OSes.
145requires_openjdk := false
146ifneq ($(EXPERIMENTAL_USE_JAVA7),)
147ifeq ($(HOST_OS), linux)
148requires_openjdk := true
149endif
150endif
151
152ifeq ($(requires_openjdk), true)
Ying Wangad690992013-09-20 17:11:43 -0700153ifeq ($(shell java -version 2>&1 | grep -i openjdk),)
154$(info ************************************************************)
Narayan Kamathe2d27882013-12-05 12:26:35 +0000155$(info You are attempting to build with an unsupported JDK.)
156$(info $(space))
Brian Carlstrom0cf57dc2014-01-20 23:48:45 -0800157$(info This build requires OpenJDK, but you are using:)
Ying Wangad690992013-09-20 17:11:43 -0700158$(info $(shell java -version 2>&1 | head -n 2).)
Narayan Kamathe2d27882013-12-05 12:26:35 +0000159$(info Please follow the machine setup instructions at)
160$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
Ying Wangad690992013-09-20 17:11:43 -0700161$(info ************************************************************)
162$(error stop)
163endif # java version is not OpenJdk
Narayan Kamathe2d27882013-12-05 12:26:35 +0000164else # if requires_openjdk
Tim Roes304f5192013-02-23 20:25:00 +0100165ifneq ($(shell java -version 2>&1 | grep -i openjdk),)
166$(info ************************************************************)
167$(info You are attempting to build with an unsupported JDK.)
168$(info $(space))
169$(info You use OpenJDK but only Sun/Oracle JDK is supported.)
170$(info Please follow the machine setup instructions at)
171$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
172$(info ************************************************************)
173$(error stop)
Ying Wangad690992013-09-20 17:11:43 -0700174endif # java version is not Sun Oracle JDK
Narayan Kamathe2d27882013-12-05 12:26:35 +0000175endif # if requires_openjdk
Joe Onorato9d9f3672009-06-22 18:15:38 -0700176
Ying Wangad690992013-09-20 17:11:43 -0700177# Check for the correct version of java, should be 1.7 if
Narayan Kamathe2d27882013-12-05 12:26:35 +0000178# EXPERIMENTAL_USE_JAVA7 is set, 1.6 otherwise.
179ifneq ($(EXPERIMENTAL_USE_JAVA7),)
180required_version := "1.7.x"
Ying Wangad690992013-09-20 17:11:43 -0700181java_version := $(shell java -version 2>&1 | head -n 1 | grep '^java .*[ "]1\.7[\. "$$]')
182javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1\.7[\. "$$]')
Narayan Kamathe2d27882013-12-05 12:26:35 +0000183else # if EXPERIMENTAL_USE_JAVA7
184required_version := "1.6.x"
Jean-Baptiste Querud7d096d2010-10-08 10:58:38 -0700185java_version := $(shell java -version 2>&1 | head -n 1 | grep '^java .*[ "]1\.6[\. "$$]')
Ying Wangad690992013-09-20 17:11:43 -0700186javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1\.6[\. "$$]')
Narayan Kamathe2d27882013-12-05 12:26:35 +0000187endif # if EXPERIMENTAL_USE_JAVA7
Ying Wangad690992013-09-20 17:11:43 -0700188
Joe Onorato9d9f3672009-06-22 18:15:38 -0700189ifeq ($(strip $(java_version)),)
190$(info ************************************************************)
191$(info You are attempting to build with the incorrect version)
192$(info of java.)
193$(info $(space))
194$(info Your version is: $(shell java -version 2>&1 | head -n 1).)
Ying Wangad690992013-09-20 17:11:43 -0700195$(info The required version is: $(required_version))
Joe Onorato9d9f3672009-06-22 18:15:38 -0700196$(info $(space))
197$(info Please follow the machine setup instructions at)
Jean-Baptiste Queru5d4bcb42012-04-19 14:53:27 -0700198$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
Joe Onorato9d9f3672009-06-22 18:15:38 -0700199$(info ************************************************************)
Jeff Hamilton4a1c70e2010-06-21 18:26:38 -0500200$(error stop)
Joe Onorato9d9f3672009-06-22 18:15:38 -0700201endif
202
203# Check for the correct version of javac
Joe Onorato9d9f3672009-06-22 18:15:38 -0700204ifeq ($(strip $(javac_version)),)
205$(info ************************************************************)
206$(info You are attempting to build with the incorrect version)
207$(info of javac.)
208$(info $(space))
209$(info Your version is: $(shell javac -version 2>&1 | head -n 1).)
Narayan Kamathe2d27882013-12-05 12:26:35 +0000210$(info The required version is: $(required_java_version))
Joe Onorato9d9f3672009-06-22 18:15:38 -0700211$(info $(space))
212$(info Please follow the machine setup instructions at)
Jean-Baptiste Queru5d4bcb42012-04-19 14:53:27 -0700213$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
Joe Onorato9d9f3672009-06-22 18:15:38 -0700214$(info ************************************************************)
Jeff Hamilton4a1c70e2010-06-21 18:26:38 -0500215$(error stop)
Joe Onorato9d9f3672009-06-22 18:15:38 -0700216endif
217
Ying Wangb036e952013-04-12 14:14:36 -0700218ifndef BUILD_EMULATOR
Ying Wang478ba5e2012-06-28 16:02:19 -0700219ifeq (darwin,$(HOST_OS))
Andrew Hsieh1dcca612012-11-09 02:06:33 -0800220GCC_REALPATH = $(realpath $(shell which $(HOST_CC)))
Ying Wang478ba5e2012-06-28 16:02:19 -0700221ifneq ($(findstring llvm-gcc,$(GCC_REALPATH)),)
222 # Using LLVM GCC results in a non functional emulator due to it
223 # not honouring global register variables
Joe Onoratoe35a4452012-07-25 17:55:03 -0700224 $(warning ****************************************)
225 $(warning * gcc is linked to llvm-gcc which will *)
226 $(warning * not create a useable emulator. *)
227 $(warning ****************************************)
Joe Onorato74e883d2012-07-25 14:28:05 -0700228 BUILD_EMULATOR := false
229else
230 BUILD_EMULATOR := true
231endif
Ying Wang7d8c5352012-07-26 10:15:21 -0700232else # HOST_OS is not darwin
233 BUILD_EMULATOR := true
234endif # HOST_OS is darwin
Ying Wangb036e952013-04-12 14:14:36 -0700235endif
Ying Wang478ba5e2012-06-28 16:02:19 -0700236
Joe Onorato1de66882009-07-30 11:54:27 -0700237$(shell echo 'VERSIONS_CHECKED := $(VERSION_CHECK_SEQUENCE_NUMBER)' \
238 > $(OUT_DIR)/versions_checked.mk)
Ying Wangb036e952013-04-12 14:14:36 -0700239$(shell echo 'BUILD_EMULATOR ?= $(BUILD_EMULATOR)' \
Joe Onoratoe35a4452012-07-25 17:55:03 -0700240 >> $(OUT_DIR)/versions_checked.mk)
Joe Onorato1de66882009-07-30 11:54:27 -0700241endif
242
The Android Open Source Project88b60792009-03-03 19:28:42 -0800243# These are the modifier targets that don't do anything themselves, but
244# change the behavior of the build.
245# (must be defined before including definitions.make)
Ying Wang31268312013-02-21 18:41:51 -0800246INTERNAL_MODIFIER_TARGETS := showcommands all incrementaljavac
Ying Wang015edd22011-01-20 15:01:56 -0800247
248.PHONY: incrementaljavac
249incrementaljavac: ;
250
251# WARNING:
252# ENABLE_INCREMENTALJAVAC should NOT be enabled by default, because change of
253# a Java source file won't trigger rebuild of its dependent Java files.
254# You can only enable it by adding "incrementaljavac" to your make command line.
255# You are responsible for the correctness of the incremental build.
256# This may decrease incremental build time dramatically for large Java libraries,
257# such as core.jar, framework.jar, etc.
258ENABLE_INCREMENTALJAVAC :=
259ifneq (,$(filter incrementaljavac, $(MAKECMDGOALS)))
260ENABLE_INCREMENTALJAVAC := true
261MAKECMDGOALS := $(filter-out incrementaljavac, $(MAKECMDGOALS))
262endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800263
Ying Wangaf4800c2012-08-21 16:59:01 -0700264# EMMA_INSTRUMENT_STATIC merges the static emma library to each emma-enabled module.
265ifeq (true,$(EMMA_INSTRUMENT_STATIC))
266EMMA_INSTRUMENT := true
267endif
268
The Android Open Source Project88b60792009-03-03 19:28:42 -0800269# Bring in standard build system definitions.
270include $(BUILD_SYSTEM)/definitions.mk
271
Ying Wange7874c42010-09-17 16:36:06 -0700272# Bring in dex_preopt.mk
273include $(BUILD_SYSTEM)/dex_preopt.mk
274
Joe Onorato6a185e42012-05-22 14:08:50 -0700275ifneq ($(filter user userdebug eng,$(MAKECMDGOALS)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800276$(info ***************************************************************)
277$(info ***************************************************************)
Ying Wangd0244b32011-11-17 14:51:12 -0800278$(info Do not pass '$(filter user userdebug eng,$(MAKECMDGOALS))' on \
279 the make command line.)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800280$(info Set TARGET_BUILD_VARIANT in buildspec.mk, or use lunch or)
281$(info choosecombo.)
282$(info ***************************************************************)
283$(info ***************************************************************)
284$(error stopping)
285endif
286
The Android Open Source Project2f312932009-03-09 11:52:11 -0700287ifneq ($(filter-out $(INTERNAL_VALID_VARIANTS),$(TARGET_BUILD_VARIANT)),)
288$(info ***************************************************************)
289$(info ***************************************************************)
290$(info Invalid variant: $(TARGET_BUILD_VARIANT)
291$(info Valid values are: $(INTERNAL_VALID_VARIANTS)
292$(info ***************************************************************)
293$(info ***************************************************************)
294$(error stopping)
295endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800296
Keun young Park7fc7aad2012-02-27 15:49:23 -0800297# -----------------------------------------------------------------
Keun young Parkefe02ce2012-06-06 17:19:29 -0700298# Variable to check java support level inside PDK build.
299# Not necessary if the components is not in PDK.
300# not defined : not supported
301# "sdk" : sdk API only
302# "platform" : platform API supproted
303TARGET_BUILD_JAVA_SUPPORT_LEVEL := platform
304
305# -----------------------------------------------------------------
Keun young Park7fc7aad2012-02-27 15:49:23 -0800306# The pdk (Platform Development Kit) build
Ying Wang82b836f2012-03-30 18:08:07 -0700307include build/core/pdk_config.mk
Keun young Park7fc7aad2012-02-27 15:49:23 -0800308
Keun young Park7fc7aad2012-02-27 15:49:23 -0800309# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800310###
311### In this section we set up the things that are different
312### between the build variants
313###
314
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700315is_sdk_build :=
Raphaelc4d47312011-02-15 16:09:36 -0800316
317ifneq ($(filter sdk win_sdk sdk_addon,$(MAKECMDGOALS)),)
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700318is_sdk_build := true
319endif
320
The Android Open Source Project88b60792009-03-03 19:28:42 -0800321## user/userdebug ##
322
Joe Onorato6a185e42012-05-22 14:08:50 -0700323user_variant := $(filter user userdebug,$(TARGET_BUILD_VARIANT))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800324enable_target_debugging := true
Joe Onorato6a185e42012-05-22 14:08:50 -0700325tags_to_install :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800326ifneq (,$(user_variant))
327 # Target is secure in user builds.
328 ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=1
329
The Android Open Source Project88b60792009-03-03 19:28:42 -0800330 ifeq ($(user_variant),userdebug)
331 # Pick up some extra useful tools
The Android Open Source Project2f312932009-03-09 11:52:11 -0700332 tags_to_install += debug
Brad Fitzpatrick135677a2010-04-16 16:55:41 -0700333
334 # Enable Dalvik lock contention logging for userdebug builds.
335 ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.lockprof.threshold=500
The Android Open Source Project88b60792009-03-03 19:28:42 -0800336 else
337 # Disable debugging in plain user builds.
338 enable_target_debugging :=
339 endif
Dan Bornsteinf13bdd92010-09-07 17:45:44 -0700340
Dan Bornsteinf7ad63a2011-05-31 10:29:47 -0700341 # Turn on Dalvik preoptimization for user builds, but only if not
342 # explicitly disabled and the build is running on Linux (since host
343 # Dalvik isn't built for non-Linux hosts).
Ying Wang02352372010-09-27 10:37:25 -0700344 ifneq (true,$(DISABLE_DEXPREOPT))
Dan Bornsteinf7ad63a2011-05-31 10:29:47 -0700345 ifeq ($(user_variant),user)
346 ifeq ($(HOST_OS),linux)
347 WITH_DEXPREOPT := true
348 endif
349 endif
Ying Wang02352372010-09-27 10:37:25 -0700350 endif
Dan Bornsteinf13bdd92010-09-07 17:45:44 -0700351
The Android Open Source Project88b60792009-03-03 19:28:42 -0800352 # Disallow mock locations by default for user builds
353 ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=0
Dan Bornsteinf13bdd92010-09-07 17:45:44 -0700354
The Android Open Source Project88b60792009-03-03 19:28:42 -0800355else # !user_variant
356 # Turn on checkjni for non-user builds.
357 ADDITIONAL_BUILD_PROPERTIES += ro.kernel.android.checkjni=1
358 # Set device insecure for non-user builds.
359 ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0
360 # Allow mock locations by default for non user builds
361 ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=1
362endif # !user_variant
363
364ifeq (true,$(strip $(enable_target_debugging)))
365 # Target is more debuggable and adbd is on by default
Mike Lockwood40b5a672011-07-01 12:31:47 -0400366 ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1
The Android Open Source Project88b60792009-03-03 19:28:42 -0800367 # Include the debugging/testing OTA keys in this build.
368 INCLUDE_TEST_OTA_KEYS := true
369else # !enable_target_debugging
370 # Target is less debuggable and adbd is off by default
Mike Lockwood40b5a672011-07-01 12:31:47 -0400371 ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0
The Android Open Source Project88b60792009-03-03 19:28:42 -0800372endif # !enable_target_debugging
373
The Android Open Source Project2f312932009-03-09 11:52:11 -0700374## eng ##
375
376ifeq ($(TARGET_BUILD_VARIANT),eng)
Joe Onorato6a185e42012-05-22 14:08:50 -0700377tags_to_install := debug eng
Bruce Beareb056d712011-12-01 12:46:12 -0800378ifneq ($(filter ro.setupwizard.mode=ENABLED, $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))),)
The Android Open Source Projectfdd3a102009-03-11 12:11:54 -0700379 # Don't require the setup wizard on eng builds
380 ADDITIONAL_BUILD_PROPERTIES := $(filter-out ro.setupwizard.mode=%,\
Joe Onorato08896612009-10-07 10:01:13 -0700381 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))) \
382 ro.setupwizard.mode=OPTIONAL
The Android Open Source Project2f312932009-03-09 11:52:11 -0700383endif
Bruce Beareb056d712011-12-01 12:46:12 -0800384endif
The Android Open Source Project2f312932009-03-09 11:52:11 -0700385
The Android Open Source Project88b60792009-03-03 19:28:42 -0800386## sdk ##
387
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700388ifdef is_sdk_build
Raphaelc4d47312011-02-15 16:09:36 -0800389
390# Detect if we want to build a repository for the SDK
391sdk_repo_goal := $(strip $(filter sdk_repo,$(MAKECMDGOALS)))
392MAKECMDGOALS := $(strip $(filter-out sdk_repo,$(MAKECMDGOALS)))
393
Ying Wangfcec57a2013-06-26 17:56:08 -0700394ifneq ($(words $(filter-out $(INTERNAL_MODIFIER_TARGETS) checkbuild,$(MAKECMDGOALS))),1)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800395$(error The 'sdk' target may not be specified with any other targets)
396endif
Raphael3d224a02010-04-16 17:50:09 -0700397
The Android Open Source Project2f312932009-03-09 11:52:11 -0700398# TODO: this should be eng I think. Since the sdk is built from the eng
399# variant.
Joe Onorato6a185e42012-05-22 14:08:50 -0700400tags_to_install := debug eng
The Android Open Source Project88b60792009-03-03 19:28:42 -0800401ADDITIONAL_BUILD_PROPERTIES += xmpp.auto-presence=true
402ADDITIONAL_BUILD_PROPERTIES += ro.config.nocheckin=yes
403else # !sdk
The Android Open Source Project88b60792009-03-03 19:28:42 -0800404endif
405
Andreas Huber200f2592010-08-30 12:48:03 -0700406BUILD_WITHOUT_PV := true
407
Andy McFadden743e2502009-04-13 14:48:35 -0700408## precise GC ##
409
410ifneq ($(filter dalvik.gc.type-precise,$(PRODUCT_TAGS)),)
411 # Enabling type-precise GC results in larger optimized DEX files. The
412 # additional storage requirements for ".odex" files can cause /system
413 # to overflow on some devices, so this is configured separately for
414 # each product.
415 ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.dexopt-flags=m=y
416endif
417
The Android Open Source Project88b60792009-03-03 19:28:42 -0800418ADDITIONAL_BUILD_PROPERTIES += net.bt.name=Android
419
420# enable vm tracing in files for now to help track
421# the cause of ANRs in the content process
422ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.stack-trace-file=/data/anr/traces.txt
423
The Android Open Source Project88b60792009-03-03 19:28:42 -0800424# ------------------------------------------------------------
425# Define a function that, given a list of module tags, returns
426# non-empty if that module should be installed in /system.
427
The Android Open Source Project2f312932009-03-09 11:52:11 -0700428# For most goals, anything not tagged with the "tests" tag should
The Android Open Source Project88b60792009-03-03 19:28:42 -0800429# be installed in /system.
430define should-install-to-system
The Android Open Source Project2f312932009-03-09 11:52:11 -0700431$(if $(filter tests,$(1)),,true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800432endef
433
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700434ifdef is_sdk_build
The Android Open Source Project88b60792009-03-03 19:28:42 -0800435# For the sdk goal, anything with the "samples" tag should be
436# installed in /data even if that module also has "eng"/"debug"/"user".
437define should-install-to-system
The Android Open Source Project2f312932009-03-09 11:52:11 -0700438$(if $(filter samples tests,$(1)),,true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800439endef
440endif
441
442
Ying Wang31268312013-02-21 18:41:51 -0800443# If they only used the modifier goals (showcommands, etc), we'll actually
Joe Onoratoe334d252009-07-17 15:33:40 -0400444# build the default target.
445ifeq ($(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS)),)
446.PHONY: $(INTERNAL_MODIFIER_TARGETS)
447$(INTERNAL_MODIFIER_TARGETS): $(DEFAULT_GOAL)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800448endif
449
The Android Open Source Project88b60792009-03-03 19:28:42 -0800450# Bring in all modules that need to be built.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800451ifeq ($(HOST_OS)-$(HOST_ARCH),darwin-ppc)
452SDK_ONLY := true
Raphael Moll7058f492010-04-13 10:38:35 -0700453$(info Building the SDK under darwin-ppc is actually obsolete and unsupported.)
454$(error stop)
455endif
456
457ifeq ($(HOST_OS),windows)
458SDK_ONLY := true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800459endif
460
461ifeq ($(SDK_ONLY),true)
Raphael Moll8a2b7702013-03-13 15:30:35 -0700462include $(TOPDIR)sdk/build/windows_sdk_whitelist.mk
463include $(TOPDIR)development/build/windows_sdk_whitelist.mk
The Android Open Source Project88b60792009-03-03 19:28:42 -0800464
465# Exclude tools/acp when cross-compiling windows under linux
466ifeq ($(findstring Linux,$(UNAME)),)
467subdirs += build/tools/acp
468endif
469
470else # !SDK_ONLY
The Android Open Source Project88b60792009-03-03 19:28:42 -0800471#
472# Typical build; include any Android.mk files we can find.
473#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800474subdirs := $(TOP)
475
476FULL_BUILD := true
477
The Android Open Source Project88b60792009-03-03 19:28:42 -0800478endif # !SDK_ONLY
479
Joe Onorato8dc8faa2010-09-14 13:09:48 -0400480# Before we go and include all of the module makefiles, stash away
Ying Wang7522f042010-10-11 16:31:49 -0700481# the PRODUCT_* values so that later we can verify they are not modified.
482stash_product_vars:=true
Joe Onorato8dc8faa2010-09-14 13:09:48 -0400483ifeq ($(stash_product_vars),true)
Ying Wang7522f042010-10-11 16:31:49 -0700484 $(call stash-product-vars, __STASHED)
Joe Onorato8dc8faa2010-09-14 13:09:48 -0400485endif
486
The Android Open Source Project88b60792009-03-03 19:28:42 -0800487ifneq ($(ONE_SHOT_MAKEFILE),)
488# We've probably been invoked by the "mm" shell function
489# with a subdirectory's makefile.
490include $(ONE_SHOT_MAKEFILE)
491# Change CUSTOM_MODULES to include only modules that were
492# defined by this makefile; this will install all of those
493# modules as a side-effect. Do this after including ONE_SHOT_MAKEFILE
494# so that the modules will be installed in the same place they
495# would have been with a normal make.
Jean-Baptiste Queru6907cfe2010-01-07 11:19:39 -0800496CUSTOM_MODULES := $(sort $(call get-tagged-modules,$(ALL_MODULE_TAGS)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800497FULL_BUILD :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800498# Stub out the notice targets, which probably aren't defined
499# when using ONE_SHOT_MAKEFILE.
500NOTICE-HOST-%: ;
501NOTICE-TARGET-%: ;
Joe Onoratoead96462009-07-30 11:20:04 -0700502
Ying Wanga7deb082013-08-16 13:24:47 -0700503# A helper goal printing out install paths
504.PHONY: GET-INSTALL-PATH
505GET-INSTALL-PATH:
506 @$(foreach m, $(ALL_MODULES), $(if $(ALL_MODULES.$(m).INSTALLED), \
507 echo 'INSTALL-PATH: $(m) $(ALL_MODULES.$(m).INSTALLED)';))
508
Joe Onoratoead96462009-07-30 11:20:04 -0700509else # ONE_SHOT_MAKEFILE
510
Ying Wang20ef3542013-09-09 12:11:02 -0700511ifneq ($(dont_bother),true)
Joe Onoratoead96462009-07-30 11:20:04 -0700512#
513# Include all of the makefiles in the system
514#
515
516# Can't use first-makefiles-under here because
517# --mindepth=2 makes the prunes not work.
518subdir_makefiles := \
JP Abgrall1390cac2013-07-11 19:08:06 -0700519 $(shell build/tools/findleaves.py --prune=$(OUT_DIR) --prune=.repo --prune=.git $(subdirs) Android.mk)
Joe Onoratoead96462009-07-30 11:20:04 -0700520
Ying Wang172f5f52013-07-31 12:18:36 -0700521$(foreach mk, $(subdir_makefiles), $(info including $(mk) ...)$(eval include $(mk)))
Ying Wang71004f82012-05-24 21:05:19 -0700522
Ying Wang20ef3542013-09-09 12:11:02 -0700523endif # dont_bother
The Android Open Source Project88b60792009-03-03 19:28:42 -0800524
Joe Onoratoead96462009-07-30 11:20:04 -0700525endif # ONE_SHOT_MAKEFILE
526
Ying Wang71004f82012-05-24 21:05:19 -0700527# Now with all Android.mks loaded we can do post cleaning steps.
528include $(BUILD_SYSTEM)/post_clean.mk
529
Joe Onorato8dc8faa2010-09-14 13:09:48 -0400530ifeq ($(stash_product_vars),true)
Ying Wang7522f042010-10-11 16:31:49 -0700531 $(call assert-product-vars, __STASHED)
Joe Onorato8dc8faa2010-09-14 13:09:48 -0400532endif
533
Jean-Baptiste Queru09447712010-09-26 13:05:41 -0700534include $(BUILD_SYSTEM)/legacy_prebuilts.mk
535ifneq ($(filter-out $(GRANDFATHERED_ALL_PREBUILT),$(strip $(notdir $(ALL_PREBUILT)))),)
536 $(warning *** Some files have been added to ALL_PREBUILT.)
537 $(warning *)
Kenny Root824d7b22010-11-18 14:27:00 -0800538 $(warning * ALL_PREBUILT is a deprecated mechanism that)
Jean-Baptiste Queru09447712010-09-26 13:05:41 -0700539 $(warning * should not be used for new files.)
540 $(warning * As an alternative, use PRODUCT_COPY_FILES in)
541 $(warning * the appropriate product definition.)
542 $(warning * build/target/product/core.mk is the product)
543 $(warning * definition used in all products.)
544 $(warning *)
545 $(foreach bad_prebuilt,$(filter-out $(GRANDFATHERED_ALL_PREBUILT),$(strip $(notdir $(ALL_PREBUILT)))),$(warning * unexpected $(bad_prebuilt) in ALL_PREBUILT))
546 $(warning *)
547 $(error ALL_PREBUILT contains unexpected files)
548endif
549
The Android Open Source Project88b60792009-03-03 19:28:42 -0800550# -------------------------------------------------------------------
551# All module makefiles have been included at this point.
552# -------------------------------------------------------------------
553
The Android Open Source Project88b60792009-03-03 19:28:42 -0800554
555# -------------------------------------------------------------------
556# Fix up CUSTOM_MODULES to refer to installed files rather than
557# just bare module names. Leave unknown modules alone in case
558# they're actually full paths to a particular file.
559known_custom_modules := $(filter $(ALL_MODULES),$(CUSTOM_MODULES))
560unknown_custom_modules := $(filter-out $(ALL_MODULES),$(CUSTOM_MODULES))
561CUSTOM_MODULES := \
562 $(call module-installed-files,$(known_custom_modules)) \
563 $(unknown_custom_modules)
564
565# -------------------------------------------------------------------
566# Define dependencies for modules that require other modules.
567# This can only happen now, after we've read in all module makefiles.
568#
569# TODO: deal with the fact that a bare module name isn't
570# unambiguous enough. Maybe declare short targets like
571# APPS:Quake or HOST:SHARED_LIBRARIES:libutils.
572# BUG: the system image won't know to depend on modules that are
573# brought in as requirements of other modules.
574define add-required-deps
Ying Wang9485a572013-02-22 14:32:30 -0800575$(1): | $(2)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800576endef
577$(foreach m,$(ALL_MODULES), \
578 $(eval r := $(ALL_MODULES.$(m).REQUIRED)) \
579 $(if $(r), \
580 $(eval r := $(call module-installed-files,$(r))) \
Ying Wang16b92ed2013-06-06 18:05:53 -0700581 $(eval t_m := $(filter $(TARGET_OUT_ROOT)/%, $(ALL_MODULES.$(m).INSTALLED))) \
582 $(eval h_m := $(filter $(HOST_OUT_ROOT)/%, $(ALL_MODULES.$(m).INSTALLED))) \
583 $(eval t_r := $(filter $(TARGET_OUT_ROOT)/%, $(r))) \
584 $(eval h_r := $(filter $(HOST_OUT_ROOT)/%, $(r))) \
585 $(if $(t_m), $(eval $(call add-required-deps, $(t_m),$(t_r)))) \
586 $(if $(h_m), $(eval $(call add-required-deps, $(h_m),$(h_r)))) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800587 ) \
588 )
Ying Wang9485a572013-02-22 14:32:30 -0800589
Ying Wang16b92ed2013-06-06 18:05:53 -0700590t_m :=
591h_m :=
592t_r :=
593h_r :=
594
Ying Wang9485a572013-02-22 14:32:30 -0800595# Resolve the dependencies on shared libraries.
596$(foreach m,$(TARGET_DEPENDENCIES_ON_SHARED_LIBRARIES), \
597 $(eval p := $(subst :,$(space),$(m))) \
598 $(eval r := $(filter $(TARGET_OUT_ROOT)/%,$(call module-installed-files,\
599 $(subst $(comma),$(space),$(lastword $(p)))))) \
Ying Wangd6b1d612013-04-15 17:32:21 -0700600 $(eval $(call add-required-deps,$(word 2,$(p)),$(r))))
Ying Wang9485a572013-02-22 14:32:30 -0800601$(foreach m,$(HOST_DEPENDENCIES_ON_SHARED_LIBRARIES), \
602 $(eval p := $(subst :,$(space),$(m))) \
603 $(eval r := $(filter $(HOST_OUT_ROOT)/%,$(call module-installed-files,\
604 $(subst $(comma),$(space),$(lastword $(p)))))) \
Ying Wangd6b1d612013-04-15 17:32:21 -0700605 $(eval $(call add-required-deps,$(word 2,$(p)),$(r))))
Ying Wang9485a572013-02-22 14:32:30 -0800606
The Android Open Source Project88b60792009-03-03 19:28:42 -0800607m :=
608r :=
Ying Wang9485a572013-02-22 14:32:30 -0800609p :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800610add-required-deps :=
611
612# -------------------------------------------------------------------
613# Figure out our module sets.
Joe Onorato6a185e42012-05-22 14:08:50 -0700614#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800615# Of the modules defined by the component makefiles,
616# determine what we actually want to build.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800617
618ifdef FULL_BUILD
619 # The base list of modules to build for this product is specified
620 # by the appropriate product definition file, which was included
621 # by product_config.make.
Joe Onorato8d0847e2012-07-11 19:38:48 -0700622 product_MODULES := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES)
Ying Wang489458f2012-08-23 15:08:34 -0700623 # Filter out the overridden packages before doing expansion
624 product_MODULES := $(filter-out $(foreach p, $(product_MODULES), \
625 $(PACKAGES.$(p).OVERRIDES)), $(product_MODULES))
Joe Onorato8d0847e2012-07-11 19:38:48 -0700626 $(call expand-required-modules,product_MODULES,$(product_MODULES))
627 product_FILES := $(call module-installed-files, $(product_MODULES))
Joe Onorato6a185e42012-05-22 14:08:50 -0700628 ifeq (0,1)
Joe Onorato8d0847e2012-07-11 19:38:48 -0700629 $(info product_FILES for $(TARGET_DEVICE) ($(INTERNAL_PRODUCT)):)
630 $(foreach p,$(product_FILES),$(info : $(p)))
Joe Onorato6a185e42012-05-22 14:08:50 -0700631 $(error done)
632 endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800633else
634 # We're not doing a full build, and are probably only including
635 # a subset of the module makefiles. Don't try to build any modules
636 # requested by the product, because we probably won't have rules
637 # to build them.
Joe Onorato8d0847e2012-07-11 19:38:48 -0700638 product_FILES :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800639endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800640
Joe Onoratod7d0afc2012-06-05 15:54:09 -0700641eng_MODULES := $(sort \
642 $(call get-tagged-modules,eng) \
643 $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_ENG)) \
644 )
645debug_MODULES := $(sort \
646 $(call get-tagged-modules,debug) \
647 $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_DEBUG)) \
648 )
649tests_MODULES := $(sort \
650 $(call get-tagged-modules,tests) \
651 $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_TESTS)) \
652 )
The Android Open Source Project88b60792009-03-03 19:28:42 -0800653
Joe Onorato6a185e42012-05-22 14:08:50 -0700654# TODO: Remove the 3 places in the tree that use ALL_DEFAULT_INSTALLED_MODULES
655# and get rid of it from this list.
Joe Onorato6a185e42012-05-22 14:08:50 -0700656modules_to_install := $(sort \
Joe Onoratoe2139442012-05-22 17:33:22 -0700657 $(ALL_DEFAULT_INSTALLED_MODULES) \
Joe Onorato8d0847e2012-07-11 19:38:48 -0700658 $(product_FILES) \
Joe Onoratoe2139442012-05-22 17:33:22 -0700659 $(foreach tag,$(tags_to_install),$($(tag)_MODULES)) \
Joe Onoratoe2139442012-05-22 17:33:22 -0700660 $(CUSTOM_MODULES) \
661 )
The Android Open Source Project88b60792009-03-03 19:28:42 -0800662
663# Some packages may override others using LOCAL_OVERRIDES_PACKAGES.
664# Filter out (do not install) any overridden packages.
The Android Open Source Project2f312932009-03-09 11:52:11 -0700665overridden_packages := $(call get-package-overrides,$(modules_to_install))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800666ifdef overridden_packages
The Android Open Source Project2f312932009-03-09 11:52:11 -0700667# old_modules_to_install := $(modules_to_install)
668 modules_to_install := \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800669 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \
The Android Open Source Project2f312932009-03-09 11:52:11 -0700670 $(modules_to_install))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800671endif
The Android Open Source Project2f312932009-03-09 11:52:11 -0700672#$(error filtered out
673# $(filter-out $(modules_to_install),$(old_modules_to_install)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800674
675# Don't include any GNU targets in the SDK. It's ok (and necessary)
676# to build the host tools, but nothing that's going to be installed
677# on the target (including static libraries).
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700678ifdef is_sdk_build
The Android Open Source Project88b60792009-03-03 19:28:42 -0800679 target_gnu_MODULES := \
680 $(filter \
681 $(TARGET_OUT_INTERMEDIATES)/% \
682 $(TARGET_OUT)/% \
683 $(TARGET_OUT_DATA)/%, \
684 $(sort $(call get-tagged-modules,gnu)))
685 $(info Removing from sdk:)$(foreach d,$(target_gnu_MODULES),$(info : $(d)))
The Android Open Source Project2f312932009-03-09 11:52:11 -0700686 modules_to_install := \
687 $(filter-out $(target_gnu_MODULES),$(modules_to_install))
Ying Wang486be822011-10-08 14:31:54 -0700688
Joe Onoratod7d0afc2012-06-05 15:54:09 -0700689 # Ensure every module listed in PRODUCT_PACKAGES* gets something installed
690 # TODO: Should we do this for all builds and not just the sdk?
Ying Wang486be822011-10-08 14:31:54 -0700691 $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES), \
Joe Onoratocea08a52012-08-17 00:09:27 -0700692 $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\
Ying Wang92cd50c2012-10-31 11:55:53 -0700693 $(error $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES has nothing to install!)))
Joe Onoratod7d0afc2012-06-05 15:54:09 -0700694 $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_DEBUG), \
Joe Onoratocea08a52012-08-17 00:09:27 -0700695 $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\
Joe Onoratoc5fbef52012-08-17 01:26:41 -0700696 $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_DEBUG has nothing to install!)))
Joe Onoratod7d0afc2012-06-05 15:54:09 -0700697 $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_ENG), \
Joe Onoratocea08a52012-08-17 00:09:27 -0700698 $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\
Joe Onoratoc5fbef52012-08-17 01:26:41 -0700699 $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_ENG has nothing to install!)))
Joe Onoratod7d0afc2012-06-05 15:54:09 -0700700 $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_TESTS), \
Joe Onoratocea08a52012-08-17 00:09:27 -0700701 $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\
Joe Onoratoc5fbef52012-08-17 01:26:41 -0700702 $(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 -0800703endif
704
Joe Onoratoe334d252009-07-17 15:33:40 -0400705# build/core/Makefile contains extra stuff that we don't want to pollute this
The Android Open Source Project88b60792009-03-03 19:28:42 -0800706# top-level makefile with. It expects that ALL_DEFAULT_INSTALLED_MODULES
707# contains everything that's built during the current make, but it also further
708# extends ALL_DEFAULT_INSTALLED_MODULES.
The Android Open Source Project2f312932009-03-09 11:52:11 -0700709ALL_DEFAULT_INSTALLED_MODULES := $(modules_to_install)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800710include $(BUILD_SYSTEM)/Makefile
The Android Open Source Project2f312932009-03-09 11:52:11 -0700711modules_to_install := $(sort $(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800712ALL_DEFAULT_INSTALLED_MODULES :=
713
Joe Onoratof93f5be2012-05-21 12:16:05 -0700714
Joe Onoratoe334d252009-07-17 15:33:40 -0400715# These are additional goals that we build, in order to make sure that there
716# is as little code as possible in the tree that doesn't build.
717modules_to_check := $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).CHECKED))
718
719# If you would like to build all goals, and not skip any intermediate
720# steps, you can pass the "all" modifier goal on the commandline.
721ifneq ($(filter all,$(MAKECMDGOALS)),)
722modules_to_check += $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).BUILT))
723endif
724
725# for easier debugging
726modules_to_check := $(sort $(modules_to_check))
727#$(error modules_to_check $(modules_to_check))
728
The Android Open Source Project88b60792009-03-03 19:28:42 -0800729# -------------------------------------------------------------------
730# This is used to to get the ordering right, you can also use these,
731# but they're considered undocumented, so don't complain if their
732# behavior changes.
733.PHONY: prebuilt
734prebuilt: $(ALL_PREBUILT)
735
736# An internal target that depends on all copied headers
737# (see copy_headers.make). Other targets that need the
738# headers to be copied first can depend on this target.
739.PHONY: all_copied_headers
740all_copied_headers: ;
741
742$(ALL_C_CPP_ETC_OBJECTS): | all_copied_headers
743
744# All the droid stuff, in directories
745.PHONY: files
Joe Onoratoe334d252009-07-17 15:33:40 -0400746files: prebuilt \
747 $(modules_to_install) \
Joe Onoratoe334d252009-07-17 15:33:40 -0400748 $(INSTALLED_ANDROID_INFO_TXT_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800749
750# -------------------------------------------------------------------
751
Joe Onoratoe334d252009-07-17 15:33:40 -0400752.PHONY: checkbuild
753checkbuild: $(modules_to_check)
Ying Wang31268312013-02-21 18:41:51 -0800754ifeq (true,$(ANDROID_BUILD_EVERYTHING_BY_DEFAULT)$(filter $(MAKECMDGOALS),checkbuild))
755droid: checkbuild
756else
757# ANDROID_BUILD_EVERYTHING_BY_DEFAULT not set, or checkbuild is one of the cmd goals.
758checkbuild: droid
759endif
Joe Onoratoe334d252009-07-17 15:33:40 -0400760
The Android Open Source Project88b60792009-03-03 19:28:42 -0800761.PHONY: ramdisk
762ramdisk: $(INSTALLED_RAMDISK_TARGET)
763
Ying Wang89686532011-12-16 11:27:52 -0800764.PHONY: factory_ramdisk
765factory_ramdisk: $(INSTALLED_FACTORY_RAMDISK_TARGET)
766
Joe Onoratoe1d191e2012-05-17 11:32:26 -0700767.PHONY: factory_bundle
768factory_bundle: $(INSTALLED_FACTORY_BUNDLE_TARGET)
769
The Android Open Source Project88b60792009-03-03 19:28:42 -0800770.PHONY: systemtarball
771systemtarball: $(INSTALLED_SYSTEMTARBALL_TARGET)
772
Bruce Beare52aac202010-06-04 15:24:49 -0700773.PHONY: boottarball
774boottarball: $(INSTALLED_BOOTTARBALL_TARGET)
775
The Android Open Source Project88b60792009-03-03 19:28:42 -0800776.PHONY: userdataimage
777userdataimage: $(INSTALLED_USERDATAIMAGE_TARGET)
778
Ying Wang9c0f3e32011-02-01 14:52:05 -0800779ifneq (,$(filter userdataimage, $(MAKECMDGOALS)))
780$(call dist-for-goals, userdataimage, $(BUILT_USERDATAIMAGE_TARGET))
781endif
782
The Android Open Source Project88b60792009-03-03 19:28:42 -0800783.PHONY: userdatatarball
784userdatatarball: $(INSTALLED_USERDATATARBALL_TARGET)
785
Ying Wang9f8e8db2011-11-04 11:37:01 -0700786.PHONY: cacheimage
787cacheimage: $(INSTALLED_CACHEIMAGE_TARGET)
788
Ying Wanga0febe52013-03-20 11:02:05 -0700789.PHONY: vendorimage
790vendorimage: $(INSTALLED_VENDORIMAGE_TARGET)
791
The Android Open Source Project88b60792009-03-03 19:28:42 -0800792.PHONY: bootimage
793bootimage: $(INSTALLED_BOOTIMAGE_TARGET)
794
Ying Wangb607f7b2013-02-08 18:01:04 -0800795# phony target that include any targets in $(ALL_MODULES)
796.PHONY: all_modules
797ifndef BUILD_MODULES_IN_PATHS
798all_modules: $(ALL_MODULES)
799else
800# BUILD_MODULES_IN_PATHS is a list of paths relative to the top of the tree
801module_path_patterns := $(foreach p, $(BUILD_MODULES_IN_PATHS),\
802 $(if $(filter %/,$(p)),$(p)%,$(p)/%))
803my_all_modules := $(sort $(foreach m, $(ALL_MODULES),$(if $(filter\
804 $(module_path_patterns), $(addsuffix /,$(ALL_MODULES.$(m).PATH))),$(m))))
805all_modules: $(my_all_modules)
806endif
807
808
The Android Open Source Project88b60792009-03-03 19:28:42 -0800809# Build files and then package it into the rom formats
810.PHONY: droidcore
811droidcore: files \
812 systemimage \
813 $(INSTALLED_BOOTIMAGE_TARGET) \
814 $(INSTALLED_RECOVERYIMAGE_TARGET) \
815 $(INSTALLED_USERDATAIMAGE_TARGET) \
Ying Wang9f8e8db2011-11-04 11:37:01 -0700816 $(INSTALLED_CACHEIMAGE_TARGET) \
Ying Wanga0febe52013-03-20 11:02:05 -0700817 $(INSTALLED_VENDORIMAGE_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800818 $(INSTALLED_FILES_FILE)
819
Ying Wang228fcef2010-12-08 20:07:48 -0800820# dist_files only for putting your library into the dist directory with a full build.
821.PHONY: dist_files
Ying Wangad8aec92010-07-13 21:08:38 -0700822
Joe Onorato16fa4b22010-06-09 16:35:58 -0700823ifneq ($(TARGET_BUILD_APPS),)
Joe Onoratoda12daf2010-06-09 18:18:31 -0700824 # 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 -0800825
Joe Onorato16fa4b22010-06-09 16:35:58 -0700826 unbundled_build_modules :=
827 ifneq ($(filter all,$(TARGET_BUILD_APPS)),)
Ying Wangc048c9b2010-06-24 15:08:33 -0700828 # If they used the magic goal "all" then build all apps in the source tree.
829 unbundled_build_modules := $(foreach m,$(sort $(ALL_MODULES)),$(if $(filter APPS,$(ALL_MODULES.$(m).CLASS)),$(m)))
Joe Onorato16fa4b22010-06-09 16:35:58 -0700830 else
831 unbundled_build_modules := $(TARGET_BUILD_APPS)
832 endif
Guang Zhu0198d6e2010-04-23 11:54:37 -0700833
Ying Wang1e1241c2013-06-12 15:25:23 -0700834 # Dist the installed files if they exist.
Ying Wangda19eaf2012-08-15 12:22:44 -0700835 apps_only_installed_files := $(foreach m,$(unbundled_build_modules),$(ALL_MODULES.$(m).INSTALLED))
Ying Wangda19eaf2012-08-15 12:22:44 -0700836 $(call dist-for-goals,apps_only, $(apps_only_installed_files))
Ying Wang1e1241c2013-06-12 15:25:23 -0700837 # For uninstallable modules such as static Java library, we have to dist the built file,
838 # as <module_name>.<suffix>
839 apps_only_dist_built_files := $(foreach m,$(unbundled_build_modules),$(if $(ALL_MODULES.$(m).INSTALLED),,\
Ying Wang495f6842013-08-27 15:04:57 -0700840 $(if $(ALL_MODULES.$(m).BUILT),$(ALL_MODULES.$(m).BUILT):$(m)$(suffix $(ALL_MODULES.$(m).BUILT)))))
Ying Wang1e1241c2013-06-12 15:25:23 -0700841 $(call dist-for-goals,apps_only, $(apps_only_dist_built_files))
Ying Wangda19eaf2012-08-15 12:22:44 -0700842
843 ifeq ($(EMMA_INSTRUMENT),true)
844 $(EMMA_META_ZIP) : $(apps_only_installed_files)
845
846 $(call dist-for-goals,apps_only, $(EMMA_META_ZIP))
847 endif
Joe Onorato16fa4b22010-06-09 16:35:58 -0700848
Ying Wangae9115a2013-08-22 20:52:47 -0700849 $(PROGUARD_DICT_ZIP) : $(apps_only_installed_files)
850 $(call dist-for-goals,apps_only, $(PROGUARD_DICT_ZIP))
851
Joe Onoratoda12daf2010-06-09 18:18:31 -0700852.PHONY: apps_only
853apps_only: $(unbundled_build_modules)
Joe Onorato16fa4b22010-06-09 16:35:58 -0700854
Joe Onoratoda12daf2010-06-09 18:18:31 -0700855droid: apps_only
856
Ying Wang62c81f82013-08-22 20:02:03 -0700857# Combine the NOTICE files for a apps_only build
858$(eval $(call combine-notice-files, \
859 $(target_notice_file_txt), \
860 $(target_notice_file_html), \
861 "Notices for files for apps:", \
862 $(TARGET_OUT_NOTICE_FILES), \
863 $(apps_only_installed_files)))
864
865
Joe Onoratoda12daf2010-06-09 18:18:31 -0700866else # TARGET_BUILD_APPS
867 $(call dist-for-goals, droidcore, \
Joe Onorato16fa4b22010-06-09 16:35:58 -0700868 $(INTERNAL_UPDATE_PACKAGE_TARGET) \
869 $(INTERNAL_OTA_PACKAGE_TARGET) \
870 $(SYMBOLS_ZIP) \
Joe Onorato16fa4b22010-06-09 16:35:58 -0700871 $(INSTALLED_FILES_FILE) \
872 $(INSTALLED_BUILD_PROP_TARGET) \
873 $(BUILT_TARGET_FILES_PACKAGE) \
874 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
Ed Heyl8532aa02010-07-01 10:07:28 -0700875 $(INSTALLED_RAMDISK_TARGET) \
Ying Wang89686532011-12-16 11:27:52 -0800876 $(INSTALLED_FACTORY_RAMDISK_TARGET) \
Joe Onoratoe1d191e2012-05-17 11:32:26 -0700877 $(INSTALLED_FACTORY_BUNDLE_TARGET) \
Joe Onorato16fa4b22010-06-09 16:35:58 -0700878 )
879
Ying Wang94de1eb2013-07-26 12:19:20 -0700880 # Put a copy of the radio/bootloader files in the dist dir.
881 $(foreach f,$(INSTALLED_RADIOIMAGE_TARGET), \
882 $(call dist-for-goals, droidcore, $(f)))
883
Colin Cross971c2462012-03-29 14:31:08 -0700884 ifneq ($(TARGET_BUILD_PDK),true)
885 $(call dist-for-goals, droidcore, \
886 $(APPS_ZIP) \
887 $(INTERNAL_EMULATOR_PACKAGE_TARGET) \
888 $(PACKAGE_STATS_FILE) \
889 )
890 endif
891
Ying Wangda19eaf2012-08-15 12:22:44 -0700892 ifeq ($(EMMA_INSTRUMENT),true)
893 $(EMMA_META_ZIP) : $(INSTALLED_SYSTEMIMAGE)
894
895 $(call dist-for-goals, dist_files, $(EMMA_META_ZIP))
896 endif
897
Joe Onoratoda12daf2010-06-09 18:18:31 -0700898# Building a full system-- the default is to build droidcore
Ying Wang228fcef2010-12-08 20:07:48 -0800899droid: droidcore dist_files
Joe Onoratoda12daf2010-06-09 18:18:31 -0700900
Ying Wangf9cd36a2010-06-15 15:43:13 -0700901endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -0800902
903.PHONY: docs
904docs: $(ALL_DOCS)
905
906.PHONY: sdk
907ALL_SDK_TARGETS := $(INTERNAL_SDK_TARGET)
908sdk: $(ALL_SDK_TARGETS)
Raphaelc4d47312011-02-15 16:09:36 -0800909$(call dist-for-goals,sdk win_sdk, \
Ying Wangbe188ca2011-03-07 16:13:32 -0800910 $(ALL_SDK_TARGETS) \
911 $(SYMBOLS_ZIP) \
912 $(INSTALLED_BUILD_PROP_TARGET) \
913)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800914
Ying Wangef4d82f2013-01-29 16:59:18 -0800915# umbrella targets to assit engineers in verifying builds
Ying Wang1d977e32013-01-30 11:22:06 -0800916.PHONY: java native target host java-host java-target native-host native-target \
Ying Wangef4d82f2013-01-29 16:59:18 -0800917 java-host-tests java-target-tests native-host-tests native-target-tests \
918 java-tests native-tests host-tests target-tests
919# some synonyms
920.PHONY: host-java target-java host-native target-native \
921 target-java-tests target-native-tests
922host-java : java-host
923target-java : java-target
924host-native : native-host
925target-native : native-target
926target-java-tests : java-target-tests
927target-native-tests : native-target-tests
928
929
Ying Wang0d570a72012-06-18 18:45:40 -0700930.PHONY: lintall
931
Ying Wang8b9b39e2010-02-25 20:20:43 -0800932.PHONY: samplecode
933sample_MODULES := $(sort $(call get-tagged-modules,samples))
934sample_APKS_DEST_PATH := $(TARGET_COMMON_OUT_ROOT)/samples
935sample_APKS_COLLECTION := \
936 $(foreach module,$(sample_MODULES),$(sample_APKS_DEST_PATH)/$(notdir $(module)))
937$(foreach module,$(sample_MODULES),$(eval $(call \
938 copy-one-file,$(module),$(sample_APKS_DEST_PATH)/$(notdir $(module)))))
939sample_ADDITIONAL_INSTALLED := \
940 $(filter-out $(modules_to_install) $(modules_to_check) $(ALL_PREBUILT),$(sample_MODULES))
941samplecode: $(sample_APKS_COLLECTION)
942 @echo "Collect sample code apks: $^"
943 # remove apks that are not intended to be installed.
944 rm -f $(sample_ADDITIONAL_INSTALLED)
945
The Android Open Source Project88b60792009-03-03 19:28:42 -0800946.PHONY: findbugs
947findbugs: $(INTERNAL_FINDBUGS_HTML_TARGET) $(INTERNAL_FINDBUGS_XML_TARGET)
948
949.PHONY: clean
The Android Open Source Project88b60792009-03-03 19:28:42 -0800950clean:
The Android Open Source Project88b60792009-03-03 19:28:42 -0800951 @rm -rf $(OUT_DIR)
952 @echo "Entire build directory removed."
953
Joe Onoratodfc5e0c2010-09-03 13:25:11 -0400954.PHONY: clobber
955clobber: clean
956
The Android Open Source Project88b60792009-03-03 19:28:42 -0800957# The rules for dataclean and installclean are defined in cleanbuild.mk.
958
959#xxx scrape this from ALL_MODULE_NAME_TAGS
960.PHONY: modules
961modules:
962 @echo "Available sub-modules:"
963 @echo "$(call module-names-for-tag-list,$(ALL_MODULE_TAGS))" | \
Evan JIANGf3806922009-01-24 00:11:30 +0800964 tr -s ' ' '\n' | sort -u | $(COLUMN)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800965
966.PHONY: showcommands
967showcommands:
968 @echo >/dev/null
Joe Onorato10649c62012-05-18 20:41:38 -0700969
970.PHONY: nothing
971nothing:
972 @echo Successfully read the makefiles.