blob: 014c0501e1b8e5d1f7e31cc63a59fde46ea740cf [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.)
38$(warning * see file://$(shell pwd)/docs/development-environment/machine-setup.html)
39$(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
52# Set up various standard variables based on configuration
53# and host information.
54include $(BUILD_SYSTEM)/config.mk
55
56# This allows us to force a clean build - included after the config.make
57# environment setup is done, but before we generate any dependencies. This
58# file does the rm -rf inline so the deps which are all done below will
59# be generated correctly
60include $(BUILD_SYSTEM)/cleanbuild.mk
61
Joe Onorato1de66882009-07-30 11:54:27 -070062VERSION_CHECK_SEQUENCE_NUMBER := 1
63-include $(OUT_DIR)/versions_checked.mk
64ifneq ($(VERSION_CHECK_SEQUENCE_NUMBER),$(VERSIONS_CHECKED))
65
66$(info Checking build tools versions...)
67
The Android Open Source Project88b60792009-03-03 19:28:42 -080068ifneq ($(HOST_OS),windows)
69ifneq ($(HOST_OS)-$(HOST_ARCH),darwin-ppc)
70# check for a case sensitive file system
71ifneq (a,$(shell mkdir -p $(OUT_DIR) ; \
72 echo a > $(OUT_DIR)/casecheck.txt; \
73 echo B > $(OUT_DIR)/CaseCheck.txt; \
74 cat $(OUT_DIR)/casecheck.txt))
75$(warning ************************************************************)
76$(warning You are building on a case-insensitive filesystem.)
77$(warning Please move your source tree to a case-sensitive filesystem.)
78$(warning ************************************************************)
79$(error Case-insensitive filesystems not supported)
80endif
81endif
82endif
83
84# Make sure that there are no spaces in the absolute path; the
85# build system can't deal with them.
86ifneq ($(words $(shell pwd)),1)
87$(warning ************************************************************)
88$(warning You are building in a directory whose absolute path contains)
89$(warning a space character:)
90$(warning $(space))
91$(warning "$(shell pwd)")
92$(warning $(space))
93$(warning Please move your source tree to a path that does not contain)
94$(warning any spaces.)
95$(warning ************************************************************)
96$(error Directory names containing spaces not supported)
97endif
98
Joe Onorato9d9f3672009-06-22 18:15:38 -070099
100# The windows build server currently uses 1.6. This will be fixed.
101ifneq ($(HOST_OS),windows)
102
103# Check for the correct version of java
104java_version := $(shell java -version 2>&1 | head -n 1 | grep '[ "]1\.5[\. "$$]')
105ifeq ($(strip $(java_version)),)
106$(info ************************************************************)
107$(info You are attempting to build with the incorrect version)
108$(info of java.)
109$(info $(space))
110$(info Your version is: $(shell java -version 2>&1 | head -n 1).)
111$(info The correct version is: 1.5.)
112$(info $(space))
113$(info Please follow the machine setup instructions at)
114$(info $(space)$(space)$(space)$(space)http://source.android.com/download)
115$(info ************************************************************)
116$(error stop)
117endif
118
119# Check for the correct version of javac
120javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1\.5[\. "$$]')
121ifeq ($(strip $(javac_version)),)
122$(info ************************************************************)
123$(info You are attempting to build with the incorrect version)
124$(info of javac.)
125$(info $(space))
126$(info Your version is: $(shell javac -version 2>&1 | head -n 1).)
127$(info The correct version is: 1.5.)
128$(info $(space))
129$(info Please follow the machine setup instructions at)
130$(info $(space)$(space)$(space)$(space)http://source.android.com/download)
131$(info ************************************************************)
132$(error stop)
133endif
134
135endif # windows
136
Joe Onorato1de66882009-07-30 11:54:27 -0700137$(shell echo 'VERSIONS_CHECKED := $(VERSION_CHECK_SEQUENCE_NUMBER)' \
138 > $(OUT_DIR)/versions_checked.mk)
139endif
140
The Android Open Source Project88b60792009-03-03 19:28:42 -0800141# These are the modifier targets that don't do anything themselves, but
142# change the behavior of the build.
143# (must be defined before including definitions.make)
Joe Onoratoe334d252009-07-17 15:33:40 -0400144INTERNAL_MODIFIER_TARGETS := showcommands checkbuild
The Android Open Source Project88b60792009-03-03 19:28:42 -0800145
146# Bring in standard build system definitions.
147include $(BUILD_SYSTEM)/definitions.mk
148
149ifneq ($(filter eng user userdebug tests,$(MAKECMDGOALS)),)
150$(info ***************************************************************)
151$(info ***************************************************************)
152$(info Don't pass '$(filter eng user userdebug tests,$(MAKECMDGOALS))' on \
153 the make command line.)
The Android Open Source Project2f312932009-03-09 11:52:11 -0700154# XXX The single quote on this line fixes gvim's syntax highlighting.
155# Without which, the rest of this file is impossible to read.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800156$(info Set TARGET_BUILD_VARIANT in buildspec.mk, or use lunch or)
157$(info choosecombo.)
158$(info ***************************************************************)
159$(info ***************************************************************)
160$(error stopping)
161endif
162
The Android Open Source Project2f312932009-03-09 11:52:11 -0700163ifneq ($(filter-out $(INTERNAL_VALID_VARIANTS),$(TARGET_BUILD_VARIANT)),)
164$(info ***************************************************************)
165$(info ***************************************************************)
166$(info Invalid variant: $(TARGET_BUILD_VARIANT)
167$(info Valid values are: $(INTERNAL_VALID_VARIANTS)
168$(info ***************************************************************)
169$(info ***************************************************************)
170$(error stopping)
171endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800172
173###
174### In this section we set up the things that are different
175### between the build variants
176###
177
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700178is_sdk_build :=
179ifneq ($(filter sdk,$(MAKECMDGOALS)),)
180is_sdk_build := true
181endif
182ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),)
183is_sdk_build := true
184endif
185
186
The Android Open Source Project88b60792009-03-03 19:28:42 -0800187## user/userdebug ##
188
189user_variant := $(filter userdebug user,$(TARGET_BUILD_VARIANT))
190enable_target_debugging := true
191ifneq (,$(user_variant))
192 # Target is secure in user builds.
193 ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=1
194
The Android Open Source Project2f312932009-03-09 11:52:11 -0700195 tags_to_install := user
The Android Open Source Project88b60792009-03-03 19:28:42 -0800196 ifeq ($(user_variant),userdebug)
197 # Pick up some extra useful tools
The Android Open Source Project2f312932009-03-09 11:52:11 -0700198 tags_to_install += debug
Brad Fitzpatrick135677a2010-04-16 16:55:41 -0700199
200 # Enable Dalvik lock contention logging for userdebug builds.
201 ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.lockprof.threshold=500
The Android Open Source Project88b60792009-03-03 19:28:42 -0800202 else
203 # Disable debugging in plain user builds.
204 enable_target_debugging :=
205 endif
206
207 # TODO: Always set WITH_DEXPREOPT (for user builds) once it works on OSX.
208 # Also, remove the corresponding block in config/product_config.make.
209 ifeq ($(HOST_OS)-$(WITH_DEXPREOPT_buildbot),linux-true)
210 WITH_DEXPREOPT := true
211 endif
212
213 # Disallow mock locations by default for user builds
214 ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=0
215
216else # !user_variant
217 # Turn on checkjni for non-user builds.
218 ADDITIONAL_BUILD_PROPERTIES += ro.kernel.android.checkjni=1
219 # Set device insecure for non-user builds.
220 ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0
221 # Allow mock locations by default for non user builds
222 ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=1
223endif # !user_variant
224
225ifeq (true,$(strip $(enable_target_debugging)))
226 # Target is more debuggable and adbd is on by default
227 ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1 persist.service.adb.enable=1
228 # Include the debugging/testing OTA keys in this build.
229 INCLUDE_TEST_OTA_KEYS := true
230else # !enable_target_debugging
231 # Target is less debuggable and adbd is off by default
232 ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0 persist.service.adb.enable=0
233endif # !enable_target_debugging
234
The Android Open Source Project2f312932009-03-09 11:52:11 -0700235## eng ##
236
237ifeq ($(TARGET_BUILD_VARIANT),eng)
238tags_to_install := user debug eng
The Android Open Source Projectfdd3a102009-03-11 12:11:54 -0700239 # Don't require the setup wizard on eng builds
240 ADDITIONAL_BUILD_PROPERTIES := $(filter-out ro.setupwizard.mode=%,\
Joe Onorato08896612009-10-07 10:01:13 -0700241 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))) \
242 ro.setupwizard.mode=OPTIONAL
The Android Open Source Project2f312932009-03-09 11:52:11 -0700243endif
244
The Android Open Source Project88b60792009-03-03 19:28:42 -0800245## tests ##
246
247ifeq ($(TARGET_BUILD_VARIANT),tests)
The Android Open Source Project2f312932009-03-09 11:52:11 -0700248tags_to_install := user debug eng tests
The Android Open Source Project88b60792009-03-03 19:28:42 -0800249endif
250
251## sdk ##
252
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700253ifdef is_sdk_build
The Android Open Source Project88b60792009-03-03 19:28:42 -0800254ifneq ($(words $(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS))),1)
255$(error The 'sdk' target may not be specified with any other targets)
256endif
The Android Open Source Project2f312932009-03-09 11:52:11 -0700257# TODO: this should be eng I think. Since the sdk is built from the eng
258# variant.
Xavier Ducrohetf3e79f92009-04-06 20:32:24 -0700259tags_to_install := user debug eng
The Android Open Source Project88b60792009-03-03 19:28:42 -0800260ADDITIONAL_BUILD_PROPERTIES += xmpp.auto-presence=true
261ADDITIONAL_BUILD_PROPERTIES += ro.config.nocheckin=yes
262else # !sdk
The Android Open Source Project88b60792009-03-03 19:28:42 -0800263endif
264
Andreas Huber64b00e32009-12-17 14:03:12 -0800265# build the full stagefright library
266ifneq ($(strip BUILD_WITH_FULL_STAGEFRIGHT),)
267BUILD_WITH_FULL_STAGEFRIGHT := true
268endif
269
Andy McFadden743e2502009-04-13 14:48:35 -0700270## precise GC ##
271
272ifneq ($(filter dalvik.gc.type-precise,$(PRODUCT_TAGS)),)
273 # Enabling type-precise GC results in larger optimized DEX files. The
274 # additional storage requirements for ".odex" files can cause /system
275 # to overflow on some devices, so this is configured separately for
276 # each product.
277 ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.dexopt-flags=m=y
278endif
279
The Android Open Source Project6bce2052009-03-13 13:04:19 -0700280# Install an apns-conf.xml file if one's not already being installed.
281ifeq (,$(filter %:system/etc/apns-conf.xml, $(PRODUCT_COPY_FILES)))
282 PRODUCT_COPY_FILES += \
283 development/data/etc/apns-conf_sdk.xml:system/etc/apns-conf.xml
284 ifeq ($(filter eng tests,$(TARGET_BUILD_VARIANT)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800285 $(warning implicitly installing apns-conf_sdk.xml)
286 endif
287endif
The Android Open Source Project6bce2052009-03-13 13:04:19 -0700288# If we're on an eng or tests build, but not on the sdk, and we have
289# a better one, use that instead.
290ifneq ($(filter eng tests,$(TARGET_BUILD_VARIANT)),)
Patrick Scott1f04a3b2009-06-09 10:34:45 -0400291 ifndef is_sdk_build
The Android Open Source Project6bce2052009-03-13 13:04:19 -0700292 apns_to_use := $(wildcard vendor/google/etc/apns-conf.xml)
293 ifneq ($(strip $(apns_to_use)),)
294 PRODUCT_COPY_FILES := \
295 $(filter-out %:system/etc/apns-conf.xml,$(PRODUCT_COPY_FILES)) \
296 $(strip $(apns_to_use)):system/etc/apns-conf.xml
297 endif
298 endif
299endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800300
301ADDITIONAL_BUILD_PROPERTIES += net.bt.name=Android
302
303# enable vm tracing in files for now to help track
304# the cause of ANRs in the content process
305ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.stack-trace-file=/data/anr/traces.txt
306
The Android Open Source Project88b60792009-03-03 19:28:42 -0800307# ------------------------------------------------------------
308# Define a function that, given a list of module tags, returns
309# non-empty if that module should be installed in /system.
310
The Android Open Source Project2f312932009-03-09 11:52:11 -0700311# For most goals, anything not tagged with the "tests" tag should
The Android Open Source Project88b60792009-03-03 19:28:42 -0800312# be installed in /system.
313define should-install-to-system
The Android Open Source Project2f312932009-03-09 11:52:11 -0700314$(if $(filter tests,$(1)),,true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800315endef
316
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700317ifdef is_sdk_build
The Android Open Source Project88b60792009-03-03 19:28:42 -0800318# For the sdk goal, anything with the "samples" tag should be
319# installed in /data even if that module also has "eng"/"debug"/"user".
320define should-install-to-system
The Android Open Source Project2f312932009-03-09 11:52:11 -0700321$(if $(filter samples tests,$(1)),,true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800322endef
323endif
324
325
Joe Onoratoe334d252009-07-17 15:33:40 -0400326# If they only used the modifier goals (showcommands, checkbuild), we'll actually
327# build the default target.
328ifeq ($(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS)),)
329.PHONY: $(INTERNAL_MODIFIER_TARGETS)
330$(INTERNAL_MODIFIER_TARGETS): $(DEFAULT_GOAL)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800331endif
332
333# These targets are going to delete stuff, don't bother including
334# the whole directory tree if that's all we're going to do
335ifeq ($(MAKECMDGOALS),clean)
336dont_bother := true
337endif
338ifeq ($(MAKECMDGOALS),clobber)
339dont_bother := true
340endif
341ifeq ($(MAKECMDGOALS),dataclean)
342dont_bother := true
343endif
344ifeq ($(MAKECMDGOALS),installclean)
345dont_bother := true
346endif
347
348# Bring in all modules that need to be built.
349ifneq ($(dont_bother),true)
350
The Android Open Source Project88b60792009-03-03 19:28:42 -0800351ifeq ($(HOST_OS),windows)
352SDK_ONLY := true
353endif
354ifeq ($(HOST_OS)-$(HOST_ARCH),darwin-ppc)
355SDK_ONLY := true
356endif
357
358ifeq ($(SDK_ONLY),true)
359
Raphael4e7b0e22010-01-12 11:14:17 -0800360# ----- SDK for Windows ------
361# These configure the build targets that are available for the SDK under Cygwin.
362# The first section defines all the C/C++ tools that can be compiled under Cygwin,
363# the second section defines all the Java ones (assuming javac is available.)
364
The Android Open Source Project88b60792009-03-03 19:28:42 -0800365subdirs := \
366 prebuilt \
367 build/libs/host \
Raphael31a8ac22009-08-11 15:36:16 -0700368 build/tools/zipalign \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800369 dalvik/dexdump \
370 dalvik/libdex \
371 dalvik/tools/dmtracedump \
Raphael Molld9b64e12009-03-31 17:20:53 -0700372 dalvik/tools/hprof-conv \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800373 development/tools/line_endings \
Raphael4e7b0e22010-01-12 11:14:17 -0800374 development/tools/etc1tool \
Raphaela62a4422009-11-17 21:20:37 -0800375 sdk/emulator/mksdcard \
376 sdk/sdklauncher \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800377 development/host \
378 external/expat \
379 external/libpng \
380 external/qemu \
381 external/sqlite/dist \
382 external/zlib \
Raphael28fcfdd2009-08-19 14:06:33 -0700383 frameworks/base/libs/utils \
384 frameworks/base/tools/aapt \
385 frameworks/base/tools/aidl \
Raphael4e7b0e22010-01-12 11:14:17 -0800386 frameworks/base/opengl/libs \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800387 system/core/adb \
388 system/core/fastboot \
389 system/core/libcutils \
390 system/core/liblog \
391 system/core/libzipfile
392
393# The following can only be built if "javac" is available.
394# This check is used when building parts of the SDK under Cygwin.
395ifneq (,$(shell which javac 2>/dev/null))
396$(warning sdk-only: javac available.)
397subdirs += \
398 build/tools/signapk \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800399 dalvik/dx \
400 dalvik/libcore \
Raphaela62a4422009-11-17 21:20:37 -0800401 sdk/archquery \
402 sdk/androidprefs \
403 sdk/apkbuilder \
404 sdk/jarutils \
Raphaele749b5a2010-01-22 18:36:37 -0800405 sdk/layoutlib_api \
Raphaela62a4422009-11-17 21:20:37 -0800406 sdk/layoutlib_utils \
407 sdk/ninepatch \
408 sdk/sdkstats \
409 sdk/sdkmanager \
410 sdk/layoutopt \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800411 development/apps \
Raphael Molla779a052009-04-16 10:54:10 -0700412 development/tools/mkstubs \
Raphael28fcfdd2009-08-19 14:06:33 -0700413 frameworks/base/tools/layoutlib \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800414 packages
415else
416$(warning sdk-only: javac not available.)
417endif
418
419# Exclude tools/acp when cross-compiling windows under linux
420ifeq ($(findstring Linux,$(UNAME)),)
421subdirs += build/tools/acp
422endif
423
424else # !SDK_ONLY
425ifeq ($(BUILD_TINY_ANDROID), true)
426
427# TINY_ANDROID is a super-minimal build configuration, handy for board
428# bringup and very low level debugging
429
The Android Open Source Project88b60792009-03-03 19:28:42 -0800430subdirs := \
431 bionic \
432 system/core \
433 build/libs \
434 build/target \
435 build/tools/acp \
436 build/tools/apriori \
437 build/tools/kcm \
438 build/tools/soslim \
439 external/elfcopy \
440 external/elfutils \
441 external/yaffs2 \
442 external/zlib
443else # !BUILD_TINY_ANDROID
444
445#
446# Typical build; include any Android.mk files we can find.
447#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800448subdirs := $(TOP)
449
450FULL_BUILD := true
451
452endif # !BUILD_TINY_ANDROID
453
454endif # !SDK_ONLY
455
The Android Open Source Project88b60792009-03-03 19:28:42 -0800456ifneq ($(ONE_SHOT_MAKEFILE),)
457# We've probably been invoked by the "mm" shell function
458# with a subdirectory's makefile.
459include $(ONE_SHOT_MAKEFILE)
460# Change CUSTOM_MODULES to include only modules that were
461# defined by this makefile; this will install all of those
462# modules as a side-effect. Do this after including ONE_SHOT_MAKEFILE
463# so that the modules will be installed in the same place they
464# would have been with a normal make.
Jean-Baptiste Queru6907cfe2010-01-07 11:19:39 -0800465CUSTOM_MODULES := $(sort $(call get-tagged-modules,$(ALL_MODULE_TAGS)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800466FULL_BUILD :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800467# Stub out the notice targets, which probably aren't defined
468# when using ONE_SHOT_MAKEFILE.
469NOTICE-HOST-%: ;
470NOTICE-TARGET-%: ;
Joe Onoratoead96462009-07-30 11:20:04 -0700471
472else # ONE_SHOT_MAKEFILE
473
474#
475# Include all of the makefiles in the system
476#
477
478# Can't use first-makefiles-under here because
479# --mindepth=2 makes the prunes not work.
480subdir_makefiles := \
Joe Onoratodc1a7282009-08-04 15:58:26 -0400481 $(shell build/tools/findleaves.py --prune=out --prune=.repo --prune=.git $(subdirs) Android.mk)
Joe Onoratoead96462009-07-30 11:20:04 -0700482
The Android Open Source Project88b60792009-03-03 19:28:42 -0800483include $(subdir_makefiles)
Joe Onoratoead96462009-07-30 11:20:04 -0700484endif # ONE_SHOT_MAKEFILE
485
The Android Open Source Project88b60792009-03-03 19:28:42 -0800486# -------------------------------------------------------------------
487# All module makefiles have been included at this point.
488# -------------------------------------------------------------------
489
490# -------------------------------------------------------------------
491# Include any makefiles that must happen after the module makefiles
492# have been included.
493# TODO: have these files register themselves via a global var rather
494# than hard-coding the list here.
495ifdef FULL_BUILD
496 # Only include this during a full build, otherwise we can't be
497 # guaranteed that any policies were included.
498 -include frameworks/policies/base/PolicyConfig.mk
499endif
500
501# -------------------------------------------------------------------
502# Fix up CUSTOM_MODULES to refer to installed files rather than
503# just bare module names. Leave unknown modules alone in case
504# they're actually full paths to a particular file.
505known_custom_modules := $(filter $(ALL_MODULES),$(CUSTOM_MODULES))
506unknown_custom_modules := $(filter-out $(ALL_MODULES),$(CUSTOM_MODULES))
507CUSTOM_MODULES := \
508 $(call module-installed-files,$(known_custom_modules)) \
509 $(unknown_custom_modules)
510
511# -------------------------------------------------------------------
512# Define dependencies for modules that require other modules.
513# This can only happen now, after we've read in all module makefiles.
514#
515# TODO: deal with the fact that a bare module name isn't
516# unambiguous enough. Maybe declare short targets like
517# APPS:Quake or HOST:SHARED_LIBRARIES:libutils.
518# BUG: the system image won't know to depend on modules that are
519# brought in as requirements of other modules.
520define add-required-deps
521$(1): $(2)
522endef
523$(foreach m,$(ALL_MODULES), \
524 $(eval r := $(ALL_MODULES.$(m).REQUIRED)) \
525 $(if $(r), \
526 $(eval r := $(call module-installed-files,$(r))) \
527 $(eval $(call add-required-deps,$(ALL_MODULES.$(m).INSTALLED),$(r))) \
528 ) \
529 )
530m :=
531r :=
532add-required-deps :=
533
534# -------------------------------------------------------------------
535# Figure out our module sets.
536
537# Of the modules defined by the component makefiles,
538# determine what we actually want to build.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800539Default_MODULES := $(sort $(ALL_DEFAULT_INSTALLED_MODULES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800540 $(CUSTOM_MODULES))
The Android Open Source Project2f312932009-03-09 11:52:11 -0700541# TODO: Remove the 3 places in the tree that use
542# ALL_DEFAULT_INSTALLED_MODULES and get rid of it from this list.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800543
544ifdef FULL_BUILD
545 # The base list of modules to build for this product is specified
546 # by the appropriate product definition file, which was included
547 # by product_config.make.
548 user_PACKAGES := $(call module-installed-files, \
549 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES))
550 ifeq (0,1)
551 $(info user packages for $(TARGET_DEVICE) ($(INTERNAL_PRODUCT)):)
552 $(foreach p,$(user_PACKAGES),$(info : $(p)))
553 $(error done)
554 endif
555else
556 # We're not doing a full build, and are probably only including
557 # a subset of the module makefiles. Don't try to build any modules
558 # requested by the product, because we probably won't have rules
559 # to build them.
560 user_PACKAGES :=
561endif
562# Use tags to get the non-APPS user modules. Use the product
563# definition files to get the APPS user modules.
Jean-Baptiste Queru75127b72010-01-07 11:44:22 -0800564user_MODULES := $(sort $(call get-tagged-modules,user))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800565user_MODULES := $(user_MODULES) $(user_PACKAGES)
566
Jean-Baptiste Queru75127b72010-01-07 11:44:22 -0800567eng_MODULES := $(sort $(call get-tagged-modules,eng))
568debug_MODULES := $(sort $(call get-tagged-modules,debug))
569tests_MODULES := $(sort $(call get-tagged-modules,tests))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800570
The Android Open Source Project2f312932009-03-09 11:52:11 -0700571ifeq ($(strip $(tags_to_install)),)
572$(error ASSERTION FAILED: tags_to_install should not be empty)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800573endif
The Android Open Source Project2f312932009-03-09 11:52:11 -0700574modules_to_install := $(sort $(Default_MODULES) \
575 $(foreach tag,$(tags_to_install),$($(tag)_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800576
577# Some packages may override others using LOCAL_OVERRIDES_PACKAGES.
578# Filter out (do not install) any overridden packages.
The Android Open Source Project2f312932009-03-09 11:52:11 -0700579overridden_packages := $(call get-package-overrides,$(modules_to_install))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800580ifdef overridden_packages
The Android Open Source Project2f312932009-03-09 11:52:11 -0700581# old_modules_to_install := $(modules_to_install)
582 modules_to_install := \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800583 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \
The Android Open Source Project2f312932009-03-09 11:52:11 -0700584 $(modules_to_install))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800585endif
The Android Open Source Project2f312932009-03-09 11:52:11 -0700586#$(error filtered out
587# $(filter-out $(modules_to_install),$(old_modules_to_install)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800588
589# Don't include any GNU targets in the SDK. It's ok (and necessary)
590# to build the host tools, but nothing that's going to be installed
591# on the target (including static libraries).
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700592ifdef is_sdk_build
The Android Open Source Project88b60792009-03-03 19:28:42 -0800593 target_gnu_MODULES := \
594 $(filter \
595 $(TARGET_OUT_INTERMEDIATES)/% \
596 $(TARGET_OUT)/% \
597 $(TARGET_OUT_DATA)/%, \
598 $(sort $(call get-tagged-modules,gnu)))
599 $(info Removing from sdk:)$(foreach d,$(target_gnu_MODULES),$(info : $(d)))
The Android Open Source Project2f312932009-03-09 11:52:11 -0700600 modules_to_install := \
601 $(filter-out $(target_gnu_MODULES),$(modules_to_install))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800602endif
603
604
Joe Onoratoe334d252009-07-17 15:33:40 -0400605# build/core/Makefile contains extra stuff that we don't want to pollute this
The Android Open Source Project88b60792009-03-03 19:28:42 -0800606# top-level makefile with. It expects that ALL_DEFAULT_INSTALLED_MODULES
607# contains everything that's built during the current make, but it also further
608# extends ALL_DEFAULT_INSTALLED_MODULES.
The Android Open Source Project2f312932009-03-09 11:52:11 -0700609ALL_DEFAULT_INSTALLED_MODULES := $(modules_to_install)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800610include $(BUILD_SYSTEM)/Makefile
The Android Open Source Project2f312932009-03-09 11:52:11 -0700611modules_to_install := $(sort $(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800612ALL_DEFAULT_INSTALLED_MODULES :=
613
614endif # dont_bother
615
Joe Onoratoe334d252009-07-17 15:33:40 -0400616# These are additional goals that we build, in order to make sure that there
617# is as little code as possible in the tree that doesn't build.
618modules_to_check := $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).CHECKED))
619
620# If you would like to build all goals, and not skip any intermediate
621# steps, you can pass the "all" modifier goal on the commandline.
622ifneq ($(filter all,$(MAKECMDGOALS)),)
623modules_to_check += $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).BUILT))
624endif
625
626# for easier debugging
627modules_to_check := $(sort $(modules_to_check))
628#$(error modules_to_check $(modules_to_check))
629
The Android Open Source Project88b60792009-03-03 19:28:42 -0800630# -------------------------------------------------------------------
631# This is used to to get the ordering right, you can also use these,
632# but they're considered undocumented, so don't complain if their
633# behavior changes.
634.PHONY: prebuilt
635prebuilt: $(ALL_PREBUILT)
636
637# An internal target that depends on all copied headers
638# (see copy_headers.make). Other targets that need the
639# headers to be copied first can depend on this target.
640.PHONY: all_copied_headers
641all_copied_headers: ;
642
643$(ALL_C_CPP_ETC_OBJECTS): | all_copied_headers
644
645# All the droid stuff, in directories
646.PHONY: files
Joe Onoratoe334d252009-07-17 15:33:40 -0400647files: prebuilt \
648 $(modules_to_install) \
649 $(modules_to_check) \
650 $(INSTALLED_ANDROID_INFO_TXT_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800651
652# -------------------------------------------------------------------
653
Joe Onoratoe334d252009-07-17 15:33:40 -0400654.PHONY: checkbuild
655checkbuild: $(modules_to_check)
656
The Android Open Source Project88b60792009-03-03 19:28:42 -0800657.PHONY: ramdisk
658ramdisk: $(INSTALLED_RAMDISK_TARGET)
659
660.PHONY: systemtarball
661systemtarball: $(INSTALLED_SYSTEMTARBALL_TARGET)
662
663.PHONY: userdataimage
664userdataimage: $(INSTALLED_USERDATAIMAGE_TARGET)
665
666.PHONY: userdatatarball
667userdatatarball: $(INSTALLED_USERDATATARBALL_TARGET)
668
669.PHONY: bootimage
670bootimage: $(INSTALLED_BOOTIMAGE_TARGET)
671
672ifeq ($(BUILD_TINY_ANDROID), true)
673INSTALLED_RECOVERYIMAGE_TARGET :=
674endif
675
676# Build files and then package it into the rom formats
677.PHONY: droidcore
678droidcore: files \
679 systemimage \
680 $(INSTALLED_BOOTIMAGE_TARGET) \
681 $(INSTALLED_RECOVERYIMAGE_TARGET) \
682 $(INSTALLED_USERDATAIMAGE_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800683 $(INSTALLED_FILES_FILE)
684
685# The actual files built by the droidcore target changes depending
686# on the build variant.
687.PHONY: droid tests
688droid tests: droidcore
689
690$(call dist-for-goals, droid, \
691 $(INTERNAL_UPDATE_PACKAGE_TARGET) \
692 $(INTERNAL_OTA_PACKAGE_TARGET) \
693 $(SYMBOLS_ZIP) \
694 $(APPS_ZIP) \
695 $(INTERNAL_EMULATOR_PACKAGE_TARGET) \
696 $(PACKAGE_STATS_FILE) \
697 $(INSTALLED_FILES_FILE) \
698 $(INSTALLED_BUILD_PROP_TARGET) \
699 $(BUILT_TARGET_FILES_PACKAGE) \
Ying Wang9a6a1e32010-03-17 17:07:39 -0700700 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800701 )
702
703# Tests are installed in userdata.img. If we're building the tests
704# variant, copy it for "make tests dist". Also copy a zip of the
705# contents of userdata.img, so that people can easily extract a
706# single .apk.
707ifeq ($(TARGET_BUILD_VARIANT),tests)
708$(call dist-for-goals, droid, \
709 $(INSTALLED_USERDATAIMAGE_TARGET) \
710 $(BUILT_TESTS_ZIP_PACKAGE) \
711 )
712endif
713
714.PHONY: docs
715docs: $(ALL_DOCS)
716
717.PHONY: sdk
718ALL_SDK_TARGETS := $(INTERNAL_SDK_TARGET)
719sdk: $(ALL_SDK_TARGETS)
Ying Wang139e3322010-03-31 17:29:04 -0700720$(call dist-for-goals,sdk, \
721 $(ALL_SDK_TARGETS) \
722 $(SYMBOLS_ZIP) \
723 )
The Android Open Source Project88b60792009-03-03 19:28:42 -0800724
725.PHONY: findbugs
726findbugs: $(INTERNAL_FINDBUGS_HTML_TARGET) $(INTERNAL_FINDBUGS_XML_TARGET)
727
728.PHONY: clean
729dirs_to_clean := \
730 $(PRODUCT_OUT) \
731 $(TARGET_COMMON_OUT_ROOT) \
732 $(HOST_OUT) \
733 $(HOST_COMMON_OUT_ROOT)
734clean:
735 @for dir in $(dirs_to_clean) ; do \
736 echo "Cleaning $$dir..."; \
737 rm -rf $$dir; \
738 done
739 @echo "Clean."; \
740
741.PHONY: clobber
742clobber:
743 @rm -rf $(OUT_DIR)
744 @echo "Entire build directory removed."
745
746# The rules for dataclean and installclean are defined in cleanbuild.mk.
747
748#xxx scrape this from ALL_MODULE_NAME_TAGS
749.PHONY: modules
750modules:
751 @echo "Available sub-modules:"
752 @echo "$(call module-names-for-tag-list,$(ALL_MODULE_TAGS))" | \
753 sed -e 's/ */\n/g' | sort -u | $(COLUMN)
754
755.PHONY: showcommands
756showcommands:
757 @echo >/dev/null