blob: a4bf3e1930dca513e7e15cb26c2c8d92ec8e01da [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
15# If a rule fails, delete $@.
16.DELETE_ON_ERROR:
17
18# Figure out where we are.
19#TOP := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
20#TOP := $(patsubst %/,%,$(TOP))
21
22# TOPDIR is the normal variable you should use, because
23# if we are executing relative to the current directory
24# it can be "", whereas TOP must be "." which causes
25# pattern matching probles when make strips off the
26# trailing "./" from paths in various places.
27#ifeq ($(TOP),.)
28#TOPDIR :=
29#else
30#TOPDIR := $(TOP)/
31#endif
32
33# check for broken versions of make
34ifeq (0,$(shell expr $$(echo $(MAKE_VERSION) | sed "s/[^0-9\.].*//") \>= 3.81))
35$(warning ********************************************************************************)
36$(warning * You are using version $(MAKE_VERSION) of make.)
37$(warning * You must upgrade to version 3.81 or greater.)
Raphael Mollbfa25872010-04-18 00:07:37 -070038$(warning * see http://source.android.com/download)
The Android Open Source Project88b60792009-03-03 19:28:42 -080039$(warning ********************************************************************************)
40$(error stopping)
41endif
42
43TOP := .
44TOPDIR :=
45
46BUILD_SYSTEM := $(TOPDIR)build/core
47
48# This is the default target. It must be the first declared target.
49DEFAULT_GOAL := droid
50$(DEFAULT_GOAL):
51
Joe Onorato77dc0a52010-05-17 18:16:11 -070052# Used to force goals to build. Only use for conditionally defined goals.
53.PHONY: FORCE
54FORCE:
55
The Android Open Source Project88b60792009-03-03 19:28:42 -080056# Set up various standard variables based on configuration
57# and host information.
58include $(BUILD_SYSTEM)/config.mk
59
60# This allows us to force a clean build - included after the config.make
61# environment setup is done, but before we generate any dependencies. This
62# file does the rm -rf inline so the deps which are all done below will
63# be generated correctly
64include $(BUILD_SYSTEM)/cleanbuild.mk
65
Joe Onorato1de66882009-07-30 11:54:27 -070066VERSION_CHECK_SEQUENCE_NUMBER := 1
67-include $(OUT_DIR)/versions_checked.mk
68ifneq ($(VERSION_CHECK_SEQUENCE_NUMBER),$(VERSIONS_CHECKED))
69
70$(info Checking build tools versions...)
71
The Android Open Source Project88b60792009-03-03 19:28:42 -080072ifneq ($(HOST_OS),windows)
73ifneq ($(HOST_OS)-$(HOST_ARCH),darwin-ppc)
74# check for a case sensitive file system
75ifneq (a,$(shell mkdir -p $(OUT_DIR) ; \
76 echo a > $(OUT_DIR)/casecheck.txt; \
77 echo B > $(OUT_DIR)/CaseCheck.txt; \
78 cat $(OUT_DIR)/casecheck.txt))
79$(warning ************************************************************)
80$(warning You are building on a case-insensitive filesystem.)
81$(warning Please move your source tree to a case-sensitive filesystem.)
82$(warning ************************************************************)
83$(error Case-insensitive filesystems not supported)
84endif
85endif
86endif
87
88# Make sure that there are no spaces in the absolute path; the
89# build system can't deal with them.
90ifneq ($(words $(shell pwd)),1)
91$(warning ************************************************************)
92$(warning You are building in a directory whose absolute path contains)
93$(warning a space character:)
94$(warning $(space))
95$(warning "$(shell pwd)")
96$(warning $(space))
97$(warning Please move your source tree to a path that does not contain)
98$(warning any spaces.)
99$(warning ************************************************************)
100$(error Directory names containing spaces not supported)
101endif
102
Joe Onorato9d9f3672009-06-22 18:15:38 -0700103
Ed Heyld83f3392010-06-11 15:22:42 -0700104# The windows build server currently uses 1.6. This will be fixed.
105ifneq ($(HOST_OS),windows)
106
Joe Onorato9d9f3672009-06-22 18:15:38 -0700107# Check for the correct version of java
Ed Heyld83f3392010-06-11 15:22:42 -0700108java_version := $(shell java -version 2>&1 | head -n 1 | grep '[ "]1\.5[\. "$$]')
Joe Onorato9d9f3672009-06-22 18:15:38 -0700109ifeq ($(strip $(java_version)),)
110$(info ************************************************************)
111$(info You are attempting to build with the incorrect version)
112$(info of java.)
113$(info $(space))
114$(info Your version is: $(shell java -version 2>&1 | head -n 1).)
Ed Heyld83f3392010-06-11 15:22:42 -0700115$(info The correct version is: 1.5.)
Joe Onorato9d9f3672009-06-22 18:15:38 -0700116$(info $(space))
117$(info Please follow the machine setup instructions at)
118$(info $(space)$(space)$(space)$(space)http://source.android.com/download)
119$(info ************************************************************)
Ed Heyld83f3392010-06-11 15:22:42 -0700120#$(error stop)
Joe Onorato9d9f3672009-06-22 18:15:38 -0700121endif
122
123# Check for the correct version of javac
Ed Heyld83f3392010-06-11 15:22:42 -0700124javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1\.5[\. "$$]')
Joe Onorato9d9f3672009-06-22 18:15:38 -0700125ifeq ($(strip $(javac_version)),)
126$(info ************************************************************)
127$(info You are attempting to build with the incorrect version)
128$(info of javac.)
129$(info $(space))
130$(info Your version is: $(shell javac -version 2>&1 | head -n 1).)
Ed Heyld83f3392010-06-11 15:22:42 -0700131$(info The correct version is: 1.5.)
Joe Onorato9d9f3672009-06-22 18:15:38 -0700132$(info $(space))
133$(info Please follow the machine setup instructions at)
134$(info $(space)$(space)$(space)$(space)http://source.android.com/download)
135$(info ************************************************************)
Ed Heyld83f3392010-06-11 15:22:42 -0700136#$(error stop)
Joe Onorato9d9f3672009-06-22 18:15:38 -0700137endif
138
Ed Heyld83f3392010-06-11 15:22:42 -0700139endif # windows
140
Joe Onorato1de66882009-07-30 11:54:27 -0700141$(shell echo 'VERSIONS_CHECKED := $(VERSION_CHECK_SEQUENCE_NUMBER)' \
142 > $(OUT_DIR)/versions_checked.mk)
143endif
144
The Android Open Source Project88b60792009-03-03 19:28:42 -0800145# These are the modifier targets that don't do anything themselves, but
146# change the behavior of the build.
147# (must be defined before including definitions.make)
Joe Onoratoe334d252009-07-17 15:33:40 -0400148INTERNAL_MODIFIER_TARGETS := showcommands checkbuild
The Android Open Source Project88b60792009-03-03 19:28:42 -0800149
150# Bring in standard build system definitions.
151include $(BUILD_SYSTEM)/definitions.mk
152
153ifneq ($(filter eng user userdebug tests,$(MAKECMDGOALS)),)
154$(info ***************************************************************)
155$(info ***************************************************************)
156$(info Don't pass '$(filter eng user userdebug tests,$(MAKECMDGOALS))' on \
157 the make command line.)
The Android Open Source Project2f312932009-03-09 11:52:11 -0700158# XXX The single quote on this line fixes gvim's syntax highlighting.
159# Without which, the rest of this file is impossible to read.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800160$(info Set TARGET_BUILD_VARIANT in buildspec.mk, or use lunch or)
161$(info choosecombo.)
162$(info ***************************************************************)
163$(info ***************************************************************)
164$(error stopping)
165endif
166
The Android Open Source Project2f312932009-03-09 11:52:11 -0700167ifneq ($(filter-out $(INTERNAL_VALID_VARIANTS),$(TARGET_BUILD_VARIANT)),)
168$(info ***************************************************************)
169$(info ***************************************************************)
170$(info Invalid variant: $(TARGET_BUILD_VARIANT)
171$(info Valid values are: $(INTERNAL_VALID_VARIANTS)
172$(info ***************************************************************)
173$(info ***************************************************************)
174$(error stopping)
175endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800176
177###
178### In this section we set up the things that are different
179### between the build variants
180###
181
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700182is_sdk_build :=
183ifneq ($(filter sdk,$(MAKECMDGOALS)),)
184is_sdk_build := true
185endif
Raphael3d224a02010-04-16 17:50:09 -0700186ifneq ($(filter win_sdk,$(MAKECMDGOALS)),)
187is_sdk_build := true
188endif
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700189ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),)
190is_sdk_build := true
191endif
192
193
The Android Open Source Project88b60792009-03-03 19:28:42 -0800194## user/userdebug ##
195
196user_variant := $(filter userdebug user,$(TARGET_BUILD_VARIANT))
197enable_target_debugging := true
198ifneq (,$(user_variant))
199 # Target is secure in user builds.
200 ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=1
201
The Android Open Source Project2f312932009-03-09 11:52:11 -0700202 tags_to_install := user
The Android Open Source Project88b60792009-03-03 19:28:42 -0800203 ifeq ($(user_variant),userdebug)
204 # Pick up some extra useful tools
The Android Open Source Project2f312932009-03-09 11:52:11 -0700205 tags_to_install += debug
Brad Fitzpatrick135677a2010-04-16 16:55:41 -0700206
207 # Enable Dalvik lock contention logging for userdebug builds.
208 ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.lockprof.threshold=500
The Android Open Source Project88b60792009-03-03 19:28:42 -0800209 else
210 # Disable debugging in plain user builds.
211 enable_target_debugging :=
212 endif
213
214 # TODO: Always set WITH_DEXPREOPT (for user builds) once it works on OSX.
215 # Also, remove the corresponding block in config/product_config.make.
216 ifeq ($(HOST_OS)-$(WITH_DEXPREOPT_buildbot),linux-true)
217 WITH_DEXPREOPT := true
218 endif
219
220 # Disallow mock locations by default for user builds
221 ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=0
222
223else # !user_variant
224 # Turn on checkjni for non-user builds.
225 ADDITIONAL_BUILD_PROPERTIES += ro.kernel.android.checkjni=1
226 # Set device insecure for non-user builds.
227 ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0
228 # Allow mock locations by default for non user builds
229 ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=1
230endif # !user_variant
231
232ifeq (true,$(strip $(enable_target_debugging)))
233 # Target is more debuggable and adbd is on by default
234 ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1 persist.service.adb.enable=1
235 # Include the debugging/testing OTA keys in this build.
236 INCLUDE_TEST_OTA_KEYS := true
237else # !enable_target_debugging
238 # Target is less debuggable and adbd is off by default
239 ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0 persist.service.adb.enable=0
240endif # !enable_target_debugging
241
The Android Open Source Project2f312932009-03-09 11:52:11 -0700242## eng ##
243
244ifeq ($(TARGET_BUILD_VARIANT),eng)
245tags_to_install := user debug eng
The Android Open Source Projectfdd3a102009-03-11 12:11:54 -0700246 # Don't require the setup wizard on eng builds
247 ADDITIONAL_BUILD_PROPERTIES := $(filter-out ro.setupwizard.mode=%,\
Joe Onorato08896612009-10-07 10:01:13 -0700248 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))) \
249 ro.setupwizard.mode=OPTIONAL
The Android Open Source Project2f312932009-03-09 11:52:11 -0700250endif
251
The Android Open Source Project88b60792009-03-03 19:28:42 -0800252## tests ##
253
254ifeq ($(TARGET_BUILD_VARIANT),tests)
The Android Open Source Project2f312932009-03-09 11:52:11 -0700255tags_to_install := user debug eng tests
The Android Open Source Project88b60792009-03-03 19:28:42 -0800256endif
257
258## sdk ##
259
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700260ifdef is_sdk_build
The Android Open Source Project88b60792009-03-03 19:28:42 -0800261ifneq ($(words $(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS))),1)
262$(error The 'sdk' target may not be specified with any other targets)
263endif
Raphael3d224a02010-04-16 17:50:09 -0700264
The Android Open Source Project2f312932009-03-09 11:52:11 -0700265# TODO: this should be eng I think. Since the sdk is built from the eng
266# variant.
Xavier Ducrohetf3e79f92009-04-06 20:32:24 -0700267tags_to_install := user debug eng
The Android Open Source Project88b60792009-03-03 19:28:42 -0800268ADDITIONAL_BUILD_PROPERTIES += xmpp.auto-presence=true
269ADDITIONAL_BUILD_PROPERTIES += ro.config.nocheckin=yes
270else # !sdk
The Android Open Source Project88b60792009-03-03 19:28:42 -0800271endif
272
Andreas Huber64b00e32009-12-17 14:03:12 -0800273# build the full stagefright library
274ifneq ($(strip BUILD_WITH_FULL_STAGEFRIGHT),)
275BUILD_WITH_FULL_STAGEFRIGHT := true
276endif
277
Andy McFadden743e2502009-04-13 14:48:35 -0700278## precise GC ##
279
280ifneq ($(filter dalvik.gc.type-precise,$(PRODUCT_TAGS)),)
281 # Enabling type-precise GC results in larger optimized DEX files. The
282 # additional storage requirements for ".odex" files can cause /system
283 # to overflow on some devices, so this is configured separately for
284 # each product.
285 ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.dexopt-flags=m=y
286endif
287
The Android Open Source Project6bce2052009-03-13 13:04:19 -0700288# Install an apns-conf.xml file if one's not already being installed.
289ifeq (,$(filter %:system/etc/apns-conf.xml, $(PRODUCT_COPY_FILES)))
290 PRODUCT_COPY_FILES += \
291 development/data/etc/apns-conf_sdk.xml:system/etc/apns-conf.xml
292 ifeq ($(filter eng tests,$(TARGET_BUILD_VARIANT)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800293 $(warning implicitly installing apns-conf_sdk.xml)
294 endif
295endif
The Android Open Source Project6bce2052009-03-13 13:04:19 -0700296# If we're on an eng or tests build, but not on the sdk, and we have
297# a better one, use that instead.
298ifneq ($(filter eng tests,$(TARGET_BUILD_VARIANT)),)
Patrick Scott1f04a3b2009-06-09 10:34:45 -0400299 ifndef is_sdk_build
The Android Open Source Project6bce2052009-03-13 13:04:19 -0700300 apns_to_use := $(wildcard vendor/google/etc/apns-conf.xml)
301 ifneq ($(strip $(apns_to_use)),)
302 PRODUCT_COPY_FILES := \
303 $(filter-out %:system/etc/apns-conf.xml,$(PRODUCT_COPY_FILES)) \
304 $(strip $(apns_to_use)):system/etc/apns-conf.xml
305 endif
306 endif
307endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800308
309ADDITIONAL_BUILD_PROPERTIES += net.bt.name=Android
310
311# enable vm tracing in files for now to help track
312# the cause of ANRs in the content process
313ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.stack-trace-file=/data/anr/traces.txt
314
The Android Open Source Project88b60792009-03-03 19:28:42 -0800315# ------------------------------------------------------------
316# Define a function that, given a list of module tags, returns
317# non-empty if that module should be installed in /system.
318
The Android Open Source Project2f312932009-03-09 11:52:11 -0700319# For most goals, anything not tagged with the "tests" tag should
The Android Open Source Project88b60792009-03-03 19:28:42 -0800320# be installed in /system.
321define should-install-to-system
The Android Open Source Project2f312932009-03-09 11:52:11 -0700322$(if $(filter tests,$(1)),,true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800323endef
324
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700325ifdef is_sdk_build
The Android Open Source Project88b60792009-03-03 19:28:42 -0800326# For the sdk goal, anything with the "samples" tag should be
327# installed in /data even if that module also has "eng"/"debug"/"user".
328define should-install-to-system
The Android Open Source Project2f312932009-03-09 11:52:11 -0700329$(if $(filter samples tests,$(1)),,true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800330endef
331endif
332
333
Joe Onoratoe334d252009-07-17 15:33:40 -0400334# If they only used the modifier goals (showcommands, checkbuild), we'll actually
335# build the default target.
336ifeq ($(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS)),)
337.PHONY: $(INTERNAL_MODIFIER_TARGETS)
338$(INTERNAL_MODIFIER_TARGETS): $(DEFAULT_GOAL)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800339endif
340
341# These targets are going to delete stuff, don't bother including
342# the whole directory tree if that's all we're going to do
343ifeq ($(MAKECMDGOALS),clean)
344dont_bother := true
345endif
346ifeq ($(MAKECMDGOALS),clobber)
347dont_bother := true
348endif
349ifeq ($(MAKECMDGOALS),dataclean)
350dont_bother := true
351endif
352ifeq ($(MAKECMDGOALS),installclean)
353dont_bother := true
354endif
355
356# Bring in all modules that need to be built.
357ifneq ($(dont_bother),true)
358
The Android Open Source Project88b60792009-03-03 19:28:42 -0800359ifeq ($(HOST_OS)-$(HOST_ARCH),darwin-ppc)
360SDK_ONLY := true
Raphael Moll7058f492010-04-13 10:38:35 -0700361$(info Building the SDK under darwin-ppc is actually obsolete and unsupported.)
362$(error stop)
363endif
364
365ifeq ($(HOST_OS),windows)
366SDK_ONLY := true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800367endif
368
369ifeq ($(SDK_ONLY),true)
370
Raphael4e7b0e22010-01-12 11:14:17 -0800371# ----- SDK for Windows ------
Raphael Moll7058f492010-04-13 10:38:35 -0700372# These configure the build targets that are available for the SDK under Windows.
373# The first section defines all the C/C++ tools that can be compiled in C/C++,
Raphael4e7b0e22010-01-12 11:14:17 -0800374# the second section defines all the Java ones (assuming javac is available.)
375
The Android Open Source Project88b60792009-03-03 19:28:42 -0800376subdirs := \
377 prebuilt \
378 build/libs/host \
Raphael31a8ac22009-08-11 15:36:16 -0700379 build/tools/zipalign \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800380 dalvik/dexdump \
381 dalvik/libdex \
382 dalvik/tools/dmtracedump \
Raphael Molld9b64e12009-03-31 17:20:53 -0700383 dalvik/tools/hprof-conv \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800384 development/tools/line_endings \
Raphael4e7b0e22010-01-12 11:14:17 -0800385 development/tools/etc1tool \
Raphaela62a4422009-11-17 21:20:37 -0800386 sdk/emulator/mksdcard \
387 sdk/sdklauncher \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800388 development/host \
389 external/expat \
390 external/libpng \
391 external/qemu \
392 external/sqlite/dist \
393 external/zlib \
Raphael Moll7058f492010-04-13 10:38:35 -0700394 frameworks/base \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800395 system/core/adb \
396 system/core/fastboot \
397 system/core/libcutils \
398 system/core/liblog \
399 system/core/libzipfile
400
401# The following can only be built if "javac" is available.
402# This check is used when building parts of the SDK under Cygwin.
403ifneq (,$(shell which javac 2>/dev/null))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800404subdirs += \
405 build/tools/signapk \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800406 dalvik/dx \
Jean-Baptiste Queruaa000342010-04-30 10:13:33 -0700407 libcore \
Raphaela62a4422009-11-17 21:20:37 -0800408 sdk/archquery \
409 sdk/androidprefs \
410 sdk/apkbuilder \
411 sdk/jarutils \
Raphaele749b5a2010-01-22 18:36:37 -0800412 sdk/layoutlib_api \
Raphaela62a4422009-11-17 21:20:37 -0800413 sdk/layoutlib_utils \
414 sdk/ninepatch \
415 sdk/sdkstats \
416 sdk/sdkmanager \
417 sdk/layoutopt \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800418 development/apps \
Raphael Molla779a052009-04-16 10:54:10 -0700419 development/tools/mkstubs \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800420 packages
421else
Raphael Moll7058f492010-04-13 10:38:35 -0700422$(warning SDK_ONLY: javac not available.)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800423endif
424
425# Exclude tools/acp when cross-compiling windows under linux
426ifeq ($(findstring Linux,$(UNAME)),)
427subdirs += build/tools/acp
428endif
429
430else # !SDK_ONLY
431ifeq ($(BUILD_TINY_ANDROID), true)
432
433# TINY_ANDROID is a super-minimal build configuration, handy for board
434# bringup and very low level debugging
435
The Android Open Source Project88b60792009-03-03 19:28:42 -0800436subdirs := \
437 bionic \
438 system/core \
439 build/libs \
440 build/target \
441 build/tools/acp \
442 build/tools/apriori \
443 build/tools/kcm \
444 build/tools/soslim \
445 external/elfcopy \
446 external/elfutils \
447 external/yaffs2 \
448 external/zlib
449else # !BUILD_TINY_ANDROID
450
451#
452# Typical build; include any Android.mk files we can find.
453#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800454subdirs := $(TOP)
455
456FULL_BUILD := true
457
458endif # !BUILD_TINY_ANDROID
459
460endif # !SDK_ONLY
461
The Android Open Source Project88b60792009-03-03 19:28:42 -0800462ifneq ($(ONE_SHOT_MAKEFILE),)
463# We've probably been invoked by the "mm" shell function
464# with a subdirectory's makefile.
465include $(ONE_SHOT_MAKEFILE)
466# Change CUSTOM_MODULES to include only modules that were
467# defined by this makefile; this will install all of those
468# modules as a side-effect. Do this after including ONE_SHOT_MAKEFILE
469# so that the modules will be installed in the same place they
470# would have been with a normal make.
Jean-Baptiste Queru6907cfe2010-01-07 11:19:39 -0800471CUSTOM_MODULES := $(sort $(call get-tagged-modules,$(ALL_MODULE_TAGS)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800472FULL_BUILD :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800473# Stub out the notice targets, which probably aren't defined
474# when using ONE_SHOT_MAKEFILE.
475NOTICE-HOST-%: ;
476NOTICE-TARGET-%: ;
Joe Onoratoead96462009-07-30 11:20:04 -0700477
478else # ONE_SHOT_MAKEFILE
479
480#
481# Include all of the makefiles in the system
482#
483
484# Can't use first-makefiles-under here because
485# --mindepth=2 makes the prunes not work.
486subdir_makefiles := \
Joe Onoratodc1a7282009-08-04 15:58:26 -0400487 $(shell build/tools/findleaves.py --prune=out --prune=.repo --prune=.git $(subdirs) Android.mk)
Joe Onoratoead96462009-07-30 11:20:04 -0700488
The Android Open Source Project88b60792009-03-03 19:28:42 -0800489include $(subdir_makefiles)
Joe Onoratoead96462009-07-30 11:20:04 -0700490endif # ONE_SHOT_MAKEFILE
491
The Android Open Source Project88b60792009-03-03 19:28:42 -0800492# -------------------------------------------------------------------
493# All module makefiles have been included at this point.
494# -------------------------------------------------------------------
495
496# -------------------------------------------------------------------
497# Include any makefiles that must happen after the module makefiles
498# have been included.
499# TODO: have these files register themselves via a global var rather
500# than hard-coding the list here.
501ifdef FULL_BUILD
502 # Only include this during a full build, otherwise we can't be
503 # guaranteed that any policies were included.
504 -include frameworks/policies/base/PolicyConfig.mk
505endif
506
507# -------------------------------------------------------------------
508# Fix up CUSTOM_MODULES to refer to installed files rather than
509# just bare module names. Leave unknown modules alone in case
510# they're actually full paths to a particular file.
511known_custom_modules := $(filter $(ALL_MODULES),$(CUSTOM_MODULES))
512unknown_custom_modules := $(filter-out $(ALL_MODULES),$(CUSTOM_MODULES))
513CUSTOM_MODULES := \
514 $(call module-installed-files,$(known_custom_modules)) \
515 $(unknown_custom_modules)
516
517# -------------------------------------------------------------------
518# Define dependencies for modules that require other modules.
519# This can only happen now, after we've read in all module makefiles.
520#
521# TODO: deal with the fact that a bare module name isn't
522# unambiguous enough. Maybe declare short targets like
523# APPS:Quake or HOST:SHARED_LIBRARIES:libutils.
524# BUG: the system image won't know to depend on modules that are
525# brought in as requirements of other modules.
526define add-required-deps
527$(1): $(2)
528endef
529$(foreach m,$(ALL_MODULES), \
530 $(eval r := $(ALL_MODULES.$(m).REQUIRED)) \
531 $(if $(r), \
532 $(eval r := $(call module-installed-files,$(r))) \
533 $(eval $(call add-required-deps,$(ALL_MODULES.$(m).INSTALLED),$(r))) \
534 ) \
535 )
536m :=
537r :=
538add-required-deps :=
539
540# -------------------------------------------------------------------
541# Figure out our module sets.
542
543# Of the modules defined by the component makefiles,
544# determine what we actually want to build.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800545Default_MODULES := $(sort $(ALL_DEFAULT_INSTALLED_MODULES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800546 $(CUSTOM_MODULES))
The Android Open Source Project2f312932009-03-09 11:52:11 -0700547# TODO: Remove the 3 places in the tree that use
548# ALL_DEFAULT_INSTALLED_MODULES and get rid of it from this list.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800549
550ifdef FULL_BUILD
551 # The base list of modules to build for this product is specified
552 # by the appropriate product definition file, which was included
553 # by product_config.make.
554 user_PACKAGES := $(call module-installed-files, \
555 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES))
556 ifeq (0,1)
557 $(info user packages for $(TARGET_DEVICE) ($(INTERNAL_PRODUCT)):)
558 $(foreach p,$(user_PACKAGES),$(info : $(p)))
559 $(error done)
560 endif
561else
562 # We're not doing a full build, and are probably only including
563 # a subset of the module makefiles. Don't try to build any modules
564 # requested by the product, because we probably won't have rules
565 # to build them.
566 user_PACKAGES :=
567endif
568# Use tags to get the non-APPS user modules. Use the product
569# definition files to get the APPS user modules.
Jean-Baptiste Queru75127b72010-01-07 11:44:22 -0800570user_MODULES := $(sort $(call get-tagged-modules,user))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800571user_MODULES := $(user_MODULES) $(user_PACKAGES)
572
Jean-Baptiste Queru75127b72010-01-07 11:44:22 -0800573eng_MODULES := $(sort $(call get-tagged-modules,eng))
574debug_MODULES := $(sort $(call get-tagged-modules,debug))
575tests_MODULES := $(sort $(call get-tagged-modules,tests))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800576
The Android Open Source Project2f312932009-03-09 11:52:11 -0700577ifeq ($(strip $(tags_to_install)),)
578$(error ASSERTION FAILED: tags_to_install should not be empty)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800579endif
The Android Open Source Project2f312932009-03-09 11:52:11 -0700580modules_to_install := $(sort $(Default_MODULES) \
581 $(foreach tag,$(tags_to_install),$($(tag)_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800582
583# Some packages may override others using LOCAL_OVERRIDES_PACKAGES.
584# Filter out (do not install) any overridden packages.
The Android Open Source Project2f312932009-03-09 11:52:11 -0700585overridden_packages := $(call get-package-overrides,$(modules_to_install))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800586ifdef overridden_packages
The Android Open Source Project2f312932009-03-09 11:52:11 -0700587# old_modules_to_install := $(modules_to_install)
588 modules_to_install := \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800589 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \
The Android Open Source Project2f312932009-03-09 11:52:11 -0700590 $(modules_to_install))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800591endif
The Android Open Source Project2f312932009-03-09 11:52:11 -0700592#$(error filtered out
593# $(filter-out $(modules_to_install),$(old_modules_to_install)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800594
595# Don't include any GNU targets in the SDK. It's ok (and necessary)
596# to build the host tools, but nothing that's going to be installed
597# on the target (including static libraries).
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700598ifdef is_sdk_build
The Android Open Source Project88b60792009-03-03 19:28:42 -0800599 target_gnu_MODULES := \
600 $(filter \
601 $(TARGET_OUT_INTERMEDIATES)/% \
602 $(TARGET_OUT)/% \
603 $(TARGET_OUT_DATA)/%, \
604 $(sort $(call get-tagged-modules,gnu)))
605 $(info Removing from sdk:)$(foreach d,$(target_gnu_MODULES),$(info : $(d)))
The Android Open Source Project2f312932009-03-09 11:52:11 -0700606 modules_to_install := \
607 $(filter-out $(target_gnu_MODULES),$(modules_to_install))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800608endif
609
610
Joe Onoratoe334d252009-07-17 15:33:40 -0400611# build/core/Makefile contains extra stuff that we don't want to pollute this
The Android Open Source Project88b60792009-03-03 19:28:42 -0800612# top-level makefile with. It expects that ALL_DEFAULT_INSTALLED_MODULES
613# contains everything that's built during the current make, but it also further
614# extends ALL_DEFAULT_INSTALLED_MODULES.
The Android Open Source Project2f312932009-03-09 11:52:11 -0700615ALL_DEFAULT_INSTALLED_MODULES := $(modules_to_install)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800616include $(BUILD_SYSTEM)/Makefile
The Android Open Source Project2f312932009-03-09 11:52:11 -0700617modules_to_install := $(sort $(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800618ALL_DEFAULT_INSTALLED_MODULES :=
619
620endif # dont_bother
621
Joe Onoratoe334d252009-07-17 15:33:40 -0400622# These are additional goals that we build, in order to make sure that there
623# is as little code as possible in the tree that doesn't build.
624modules_to_check := $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).CHECKED))
625
626# If you would like to build all goals, and not skip any intermediate
627# steps, you can pass the "all" modifier goal on the commandline.
628ifneq ($(filter all,$(MAKECMDGOALS)),)
629modules_to_check += $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).BUILT))
630endif
631
632# for easier debugging
633modules_to_check := $(sort $(modules_to_check))
634#$(error modules_to_check $(modules_to_check))
635
The Android Open Source Project88b60792009-03-03 19:28:42 -0800636# -------------------------------------------------------------------
637# This is used to to get the ordering right, you can also use these,
638# but they're considered undocumented, so don't complain if their
639# behavior changes.
640.PHONY: prebuilt
641prebuilt: $(ALL_PREBUILT)
642
643# An internal target that depends on all copied headers
644# (see copy_headers.make). Other targets that need the
645# headers to be copied first can depend on this target.
646.PHONY: all_copied_headers
647all_copied_headers: ;
648
649$(ALL_C_CPP_ETC_OBJECTS): | all_copied_headers
650
651# All the droid stuff, in directories
652.PHONY: files
Joe Onoratoe334d252009-07-17 15:33:40 -0400653files: prebuilt \
654 $(modules_to_install) \
655 $(modules_to_check) \
656 $(INSTALLED_ANDROID_INFO_TXT_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800657
658# -------------------------------------------------------------------
659
Joe Onoratoe334d252009-07-17 15:33:40 -0400660.PHONY: checkbuild
661checkbuild: $(modules_to_check)
662
The Android Open Source Project88b60792009-03-03 19:28:42 -0800663.PHONY: ramdisk
664ramdisk: $(INSTALLED_RAMDISK_TARGET)
665
666.PHONY: systemtarball
667systemtarball: $(INSTALLED_SYSTEMTARBALL_TARGET)
668
669.PHONY: userdataimage
670userdataimage: $(INSTALLED_USERDATAIMAGE_TARGET)
671
672.PHONY: userdatatarball
673userdatatarball: $(INSTALLED_USERDATATARBALL_TARGET)
674
675.PHONY: bootimage
676bootimage: $(INSTALLED_BOOTIMAGE_TARGET)
677
678ifeq ($(BUILD_TINY_ANDROID), true)
679INSTALLED_RECOVERYIMAGE_TARGET :=
680endif
681
682# Build files and then package it into the rom formats
683.PHONY: droidcore
684droidcore: files \
685 systemimage \
686 $(INSTALLED_BOOTIMAGE_TARGET) \
687 $(INSTALLED_RECOVERYIMAGE_TARGET) \
688 $(INSTALLED_USERDATAIMAGE_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800689 $(INSTALLED_FILES_FILE)
690
691# The actual files built by the droidcore target changes depending
692# on the build variant.
693.PHONY: droid tests
Ying Wang1a031e42010-05-10 16:35:39 -0700694ifeq ($(strip $(is_unbundled_app_build)),true)
Ying Wang00f3a022010-05-19 17:03:14 -0700695unbundled_build_modules :=
696ifdef UNBUNDLED_APPS
697unbundled_build_modules := $(UNBUNDLED_APPS)
698else # UNBUNDLED_APPS
699# Otherwise we build all modules in the source tree.
Ying Wang1a031e42010-05-10 16:35:39 -0700700unbundled_build_modules := $(sort $(call get-tagged-modules,$(ALL_MODULE_TAGS)))
Ying Wang00f3a022010-05-19 17:03:14 -0700701endif # UNBUNDLED_APPS
Ying Wang1a031e42010-05-10 16:35:39 -0700702droid: $(unbundled_build_modules)
Ying Wang00f3a022010-05-19 17:03:14 -0700703else # is_unbundled_app_build
Ying Wang1a031e42010-05-10 16:35:39 -0700704droid: droidcore
Ying Wang00f3a022010-05-19 17:03:14 -0700705endif # is_unbundled_app_build
Ying Wang1a031e42010-05-10 16:35:39 -0700706tests: droidcore
The Android Open Source Project88b60792009-03-03 19:28:42 -0800707
Ying Wanga37a2cb2010-04-28 12:59:51 -0700708# Dist for droid if droid is among the cmd goals, or no cmd goal is given.
709ifneq ($(filter droid,$(MAKECMDGOALS))$(filter ||,|$(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS))|),)
Ying Wangebd5a9e2010-05-11 14:36:32 -0700710ifneq ($(strip $(is_unbundled_app_build)),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800711$(call dist-for-goals, droid, \
712 $(INTERNAL_UPDATE_PACKAGE_TARGET) \
713 $(INTERNAL_OTA_PACKAGE_TARGET) \
714 $(SYMBOLS_ZIP) \
715 $(APPS_ZIP) \
716 $(INTERNAL_EMULATOR_PACKAGE_TARGET) \
717 $(PACKAGE_STATS_FILE) \
718 $(INSTALLED_FILES_FILE) \
719 $(INSTALLED_BUILD_PROP_TARGET) \
720 $(BUILT_TARGET_FILES_PACKAGE) \
Ying Wang9a6a1e32010-03-17 17:07:39 -0700721 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
Ying Wang929cdf32010-04-20 11:02:45 -0700722 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800723 )
724
Guang Zhu0198d6e2010-04-23 11:54:37 -0700725ifeq ($(EMMA_INSTRUMENT),true)
726$(call dist-for-goals, droid, \
727 $(EMMA_META_ZIP) \
728 )
Ying Wanga37a2cb2010-04-28 12:59:51 -0700729endif # EMMA_INSTRUMENT
Guang Zhu0198d6e2010-04-23 11:54:37 -0700730
The Android Open Source Project88b60792009-03-03 19:28:42 -0800731# Tests are installed in userdata.img. If we're building the tests
732# variant, copy it for "make tests dist". Also copy a zip of the
733# contents of userdata.img, so that people can easily extract a
734# single .apk.
735ifeq ($(TARGET_BUILD_VARIANT),tests)
736$(call dist-for-goals, droid, \
737 $(INSTALLED_USERDATAIMAGE_TARGET) \
738 $(BUILT_TESTS_ZIP_PACKAGE) \
739 )
Ying Wanga37a2cb2010-04-28 12:59:51 -0700740endif # tests
Ying Wangebd5a9e2010-05-11 14:36:32 -0700741
742else # is_unbundled_app_build
743# dist the unbundled app.
Ying Wang00f3a022010-05-19 17:03:14 -0700744ifdef UNBUNDLED_APPS
Ying Wangebd5a9e2010-05-11 14:36:32 -0700745 $(call dist-for-goals,droid, \
Ying Wang00f3a022010-05-19 17:03:14 -0700746 $(foreach m,$(UNBUNDLED_APPS),$(ALL_MODULES.$(m).INSTALLED)) \
Ying Wangebd5a9e2010-05-11 14:36:32 -0700747 )
Ying Wang00f3a022010-05-19 17:03:14 -0700748endif # UNBUNDLED_APPS
Ying Wangebd5a9e2010-05-11 14:36:32 -0700749endif # is_unbundled_app_build
Ying Wanga37a2cb2010-04-28 12:59:51 -0700750endif # droid in $(MAKECMDGOALS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800751
752.PHONY: docs
753docs: $(ALL_DOCS)
754
755.PHONY: sdk
756ALL_SDK_TARGETS := $(INTERNAL_SDK_TARGET)
757sdk: $(ALL_SDK_TARGETS)
Ying Wanga37a2cb2010-04-28 12:59:51 -0700758ifneq ($(filter sdk,$(MAKECMDGOALS)),)
Ying Wang139e3322010-03-31 17:29:04 -0700759$(call dist-for-goals,sdk, \
760 $(ALL_SDK_TARGETS) \
761 $(SYMBOLS_ZIP) \
762 )
Ying Wanga37a2cb2010-04-28 12:59:51 -0700763endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800764
Ying Wang8b9b39e2010-02-25 20:20:43 -0800765.PHONY: samplecode
766sample_MODULES := $(sort $(call get-tagged-modules,samples))
767sample_APKS_DEST_PATH := $(TARGET_COMMON_OUT_ROOT)/samples
768sample_APKS_COLLECTION := \
769 $(foreach module,$(sample_MODULES),$(sample_APKS_DEST_PATH)/$(notdir $(module)))
770$(foreach module,$(sample_MODULES),$(eval $(call \
771 copy-one-file,$(module),$(sample_APKS_DEST_PATH)/$(notdir $(module)))))
772sample_ADDITIONAL_INSTALLED := \
773 $(filter-out $(modules_to_install) $(modules_to_check) $(ALL_PREBUILT),$(sample_MODULES))
774samplecode: $(sample_APKS_COLLECTION)
775 @echo "Collect sample code apks: $^"
776 # remove apks that are not intended to be installed.
777 rm -f $(sample_ADDITIONAL_INSTALLED)
778
The Android Open Source Project88b60792009-03-03 19:28:42 -0800779.PHONY: findbugs
780findbugs: $(INTERNAL_FINDBUGS_HTML_TARGET) $(INTERNAL_FINDBUGS_XML_TARGET)
781
782.PHONY: clean
783dirs_to_clean := \
784 $(PRODUCT_OUT) \
785 $(TARGET_COMMON_OUT_ROOT) \
786 $(HOST_OUT) \
787 $(HOST_COMMON_OUT_ROOT)
788clean:
789 @for dir in $(dirs_to_clean) ; do \
790 echo "Cleaning $$dir..."; \
791 rm -rf $$dir; \
792 done
793 @echo "Clean."; \
794
795.PHONY: clobber
796clobber:
797 @rm -rf $(OUT_DIR)
798 @echo "Entire build directory removed."
799
800# The rules for dataclean and installclean are defined in cleanbuild.mk.
801
802#xxx scrape this from ALL_MODULE_NAME_TAGS
803.PHONY: modules
804modules:
805 @echo "Available sub-modules:"
806 @echo "$(call module-names-for-tag-list,$(ALL_MODULE_TAGS))" | \
Evan JIANGf3806922009-01-24 00:11:30 +0800807 tr -s ' ' '\n' | sort -u | $(COLUMN)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800808
809.PHONY: showcommands
810showcommands:
811 @echo >/dev/null