blob: 3da799b4edf3e48e98569c0e7b499365f1565bb4 [file] [log] [blame]
Ying Wang2ce495a2010-03-30 12:55:13 -07001ifdef ANDROID_BUILD_SHELL
2SHELL := $(ANDROID_BUILD_SHELL)
3else
The Android Open Source Project88b60792009-03-03 19:28:42 -08004# Use bash, not whatever shell somebody has installed as /bin/sh
5# This is repeated in config.mk, since envsetup.sh runs that file
6# directly.
7SHELL := /bin/bash
Ying Wang2ce495a2010-03-30 12:55:13 -07008endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08009
10# this turns off the suffix rules built into make
11.SUFFIXES:
12
13# If a rule fails, delete $@.
14.DELETE_ON_ERROR:
15
16# Figure out where we are.
17#TOP := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
18#TOP := $(patsubst %/,%,$(TOP))
19
20# TOPDIR is the normal variable you should use, because
21# if we are executing relative to the current directory
22# it can be "", whereas TOP must be "." which causes
23# pattern matching probles when make strips off the
24# trailing "./" from paths in various places.
25#ifeq ($(TOP),.)
26#TOPDIR :=
27#else
28#TOPDIR := $(TOP)/
29#endif
30
31# check for broken versions of make
32ifeq (0,$(shell expr $$(echo $(MAKE_VERSION) | sed "s/[^0-9\.].*//") \>= 3.81))
33$(warning ********************************************************************************)
34$(warning * You are using version $(MAKE_VERSION) of make.)
35$(warning * You must upgrade to version 3.81 or greater.)
36$(warning * see file://$(shell pwd)/docs/development-environment/machine-setup.html)
37$(warning ********************************************************************************)
38$(error stopping)
39endif
40
41TOP := .
42TOPDIR :=
43
44BUILD_SYSTEM := $(TOPDIR)build/core
45
46# This is the default target. It must be the first declared target.
47DEFAULT_GOAL := droid
48$(DEFAULT_GOAL):
49
50# Set up various standard variables based on configuration
51# and host information.
52include $(BUILD_SYSTEM)/config.mk
53
54# This allows us to force a clean build - included after the config.make
55# environment setup is done, but before we generate any dependencies. This
56# file does the rm -rf inline so the deps which are all done below will
57# be generated correctly
58include $(BUILD_SYSTEM)/cleanbuild.mk
59
Joe Onorato1de66882009-07-30 11:54:27 -070060VERSION_CHECK_SEQUENCE_NUMBER := 1
61-include $(OUT_DIR)/versions_checked.mk
62ifneq ($(VERSION_CHECK_SEQUENCE_NUMBER),$(VERSIONS_CHECKED))
63
64$(info Checking build tools versions...)
65
The Android Open Source Project88b60792009-03-03 19:28:42 -080066ifneq ($(HOST_OS),windows)
67ifneq ($(HOST_OS)-$(HOST_ARCH),darwin-ppc)
68# check for a case sensitive file system
69ifneq (a,$(shell mkdir -p $(OUT_DIR) ; \
70 echo a > $(OUT_DIR)/casecheck.txt; \
71 echo B > $(OUT_DIR)/CaseCheck.txt; \
72 cat $(OUT_DIR)/casecheck.txt))
73$(warning ************************************************************)
74$(warning You are building on a case-insensitive filesystem.)
75$(warning Please move your source tree to a case-sensitive filesystem.)
76$(warning ************************************************************)
77$(error Case-insensitive filesystems not supported)
78endif
79endif
80endif
81
82# Make sure that there are no spaces in the absolute path; the
83# build system can't deal with them.
84ifneq ($(words $(shell pwd)),1)
85$(warning ************************************************************)
86$(warning You are building in a directory whose absolute path contains)
87$(warning a space character:)
88$(warning $(space))
89$(warning "$(shell pwd)")
90$(warning $(space))
91$(warning Please move your source tree to a path that does not contain)
92$(warning any spaces.)
93$(warning ************************************************************)
94$(error Directory names containing spaces not supported)
95endif
96
Joe Onorato9d9f3672009-06-22 18:15:38 -070097
98# The windows build server currently uses 1.6. This will be fixed.
99ifneq ($(HOST_OS),windows)
100
101# Check for the correct version of java
102java_version := $(shell java -version 2>&1 | head -n 1 | grep '[ "]1\.5[\. "$$]')
103ifeq ($(strip $(java_version)),)
104$(info ************************************************************)
105$(info You are attempting to build with the incorrect version)
106$(info of java.)
107$(info $(space))
108$(info Your version is: $(shell java -version 2>&1 | head -n 1).)
109$(info The correct version is: 1.5.)
110$(info $(space))
111$(info Please follow the machine setup instructions at)
112$(info $(space)$(space)$(space)$(space)http://source.android.com/download)
113$(info ************************************************************)
114$(error stop)
115endif
116
117# Check for the correct version of javac
118javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1\.5[\. "$$]')
119ifeq ($(strip $(javac_version)),)
120$(info ************************************************************)
121$(info You are attempting to build with the incorrect version)
122$(info of javac.)
123$(info $(space))
124$(info Your version is: $(shell javac -version 2>&1 | head -n 1).)
125$(info The correct version is: 1.5.)
126$(info $(space))
127$(info Please follow the machine setup instructions at)
128$(info $(space)$(space)$(space)$(space)http://source.android.com/download)
129$(info ************************************************************)
130$(error stop)
131endif
132
133endif # windows
134
Joe Onorato1de66882009-07-30 11:54:27 -0700135$(shell echo 'VERSIONS_CHECKED := $(VERSION_CHECK_SEQUENCE_NUMBER)' \
136 > $(OUT_DIR)/versions_checked.mk)
137endif
138
The Android Open Source Project88b60792009-03-03 19:28:42 -0800139# These are the modifier targets that don't do anything themselves, but
140# change the behavior of the build.
141# (must be defined before including definitions.make)
Joe Onoratoe334d252009-07-17 15:33:40 -0400142INTERNAL_MODIFIER_TARGETS := showcommands checkbuild
The Android Open Source Project88b60792009-03-03 19:28:42 -0800143
144# Bring in standard build system definitions.
145include $(BUILD_SYSTEM)/definitions.mk
146
147ifneq ($(filter eng user userdebug tests,$(MAKECMDGOALS)),)
148$(info ***************************************************************)
149$(info ***************************************************************)
150$(info Don't pass '$(filter eng user userdebug tests,$(MAKECMDGOALS))' on \
151 the make command line.)
The Android Open Source Project2f312932009-03-09 11:52:11 -0700152# XXX The single quote on this line fixes gvim's syntax highlighting.
153# Without which, the rest of this file is impossible to read.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800154$(info Set TARGET_BUILD_VARIANT in buildspec.mk, or use lunch or)
155$(info choosecombo.)
156$(info ***************************************************************)
157$(info ***************************************************************)
158$(error stopping)
159endif
160
The Android Open Source Project2f312932009-03-09 11:52:11 -0700161ifneq ($(filter-out $(INTERNAL_VALID_VARIANTS),$(TARGET_BUILD_VARIANT)),)
162$(info ***************************************************************)
163$(info ***************************************************************)
164$(info Invalid variant: $(TARGET_BUILD_VARIANT)
165$(info Valid values are: $(INTERNAL_VALID_VARIANTS)
166$(info ***************************************************************)
167$(info ***************************************************************)
168$(error stopping)
169endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800170
171###
172### In this section we set up the things that are different
173### between the build variants
174###
175
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700176is_sdk_build :=
177ifneq ($(filter sdk,$(MAKECMDGOALS)),)
178is_sdk_build := true
179endif
180ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),)
181is_sdk_build := true
182endif
183
184
The Android Open Source Project88b60792009-03-03 19:28:42 -0800185## user/userdebug ##
186
187user_variant := $(filter userdebug user,$(TARGET_BUILD_VARIANT))
188enable_target_debugging := true
189ifneq (,$(user_variant))
190 # Target is secure in user builds.
191 ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=1
192
The Android Open Source Project2f312932009-03-09 11:52:11 -0700193 tags_to_install := user
The Android Open Source Project88b60792009-03-03 19:28:42 -0800194 ifeq ($(user_variant),userdebug)
195 # Pick up some extra useful tools
The Android Open Source Project2f312932009-03-09 11:52:11 -0700196 tags_to_install += debug
The Android Open Source Project88b60792009-03-03 19:28:42 -0800197 else
198 # Disable debugging in plain user builds.
199 enable_target_debugging :=
200 endif
201
202 # TODO: Always set WITH_DEXPREOPT (for user builds) once it works on OSX.
203 # Also, remove the corresponding block in config/product_config.make.
204 ifeq ($(HOST_OS)-$(WITH_DEXPREOPT_buildbot),linux-true)
205 WITH_DEXPREOPT := true
206 endif
207
208 # Disallow mock locations by default for user builds
209 ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=0
210
211else # !user_variant
212 # Turn on checkjni for non-user builds.
213 ADDITIONAL_BUILD_PROPERTIES += ro.kernel.android.checkjni=1
214 # Set device insecure for non-user builds.
215 ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0
216 # Allow mock locations by default for non user builds
217 ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=1
218endif # !user_variant
219
220ifeq (true,$(strip $(enable_target_debugging)))
221 # Target is more debuggable and adbd is on by default
222 ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1 persist.service.adb.enable=1
223 # Include the debugging/testing OTA keys in this build.
224 INCLUDE_TEST_OTA_KEYS := true
225else # !enable_target_debugging
226 # Target is less debuggable and adbd is off by default
227 ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0 persist.service.adb.enable=0
228endif # !enable_target_debugging
229
The Android Open Source Project2f312932009-03-09 11:52:11 -0700230## eng ##
231
232ifeq ($(TARGET_BUILD_VARIANT),eng)
233tags_to_install := user debug eng
The Android Open Source Projectfdd3a102009-03-11 12:11:54 -0700234 # Don't require the setup wizard on eng builds
235 ADDITIONAL_BUILD_PROPERTIES := $(filter-out ro.setupwizard.mode=%,\
Joe Onorato08896612009-10-07 10:01:13 -0700236 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))) \
237 ro.setupwizard.mode=OPTIONAL
The Android Open Source Project2f312932009-03-09 11:52:11 -0700238endif
239
The Android Open Source Project88b60792009-03-03 19:28:42 -0800240## tests ##
241
242ifeq ($(TARGET_BUILD_VARIANT),tests)
The Android Open Source Project2f312932009-03-09 11:52:11 -0700243tags_to_install := user debug eng tests
The Android Open Source Project88b60792009-03-03 19:28:42 -0800244endif
245
246## sdk ##
247
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700248ifdef is_sdk_build
The Android Open Source Project88b60792009-03-03 19:28:42 -0800249ifneq ($(words $(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS))),1)
250$(error The 'sdk' target may not be specified with any other targets)
251endif
The Android Open Source Project2f312932009-03-09 11:52:11 -0700252# TODO: this should be eng I think. Since the sdk is built from the eng
253# variant.
Xavier Ducrohetf3e79f92009-04-06 20:32:24 -0700254tags_to_install := user debug eng
The Android Open Source Project88b60792009-03-03 19:28:42 -0800255ADDITIONAL_BUILD_PROPERTIES += xmpp.auto-presence=true
256ADDITIONAL_BUILD_PROPERTIES += ro.config.nocheckin=yes
257else # !sdk
The Android Open Source Project88b60792009-03-03 19:28:42 -0800258endif
259
Andreas Huber64b00e32009-12-17 14:03:12 -0800260# build the full stagefright library
261ifneq ($(strip BUILD_WITH_FULL_STAGEFRIGHT),)
262BUILD_WITH_FULL_STAGEFRIGHT := true
263endif
264
Andy McFadden743e2502009-04-13 14:48:35 -0700265## precise GC ##
266
267ifneq ($(filter dalvik.gc.type-precise,$(PRODUCT_TAGS)),)
268 # Enabling type-precise GC results in larger optimized DEX files. The
269 # additional storage requirements for ".odex" files can cause /system
270 # to overflow on some devices, so this is configured separately for
271 # each product.
272 ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.dexopt-flags=m=y
273endif
274
The Android Open Source Project6bce2052009-03-13 13:04:19 -0700275# Install an apns-conf.xml file if one's not already being installed.
276ifeq (,$(filter %:system/etc/apns-conf.xml, $(PRODUCT_COPY_FILES)))
277 PRODUCT_COPY_FILES += \
278 development/data/etc/apns-conf_sdk.xml:system/etc/apns-conf.xml
279 ifeq ($(filter eng tests,$(TARGET_BUILD_VARIANT)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800280 $(warning implicitly installing apns-conf_sdk.xml)
281 endif
282endif
The Android Open Source Project6bce2052009-03-13 13:04:19 -0700283# If we're on an eng or tests build, but not on the sdk, and we have
284# a better one, use that instead.
285ifneq ($(filter eng tests,$(TARGET_BUILD_VARIANT)),)
Patrick Scott1f04a3b2009-06-09 10:34:45 -0400286 ifndef is_sdk_build
The Android Open Source Project6bce2052009-03-13 13:04:19 -0700287 apns_to_use := $(wildcard vendor/google/etc/apns-conf.xml)
288 ifneq ($(strip $(apns_to_use)),)
289 PRODUCT_COPY_FILES := \
290 $(filter-out %:system/etc/apns-conf.xml,$(PRODUCT_COPY_FILES)) \
291 $(strip $(apns_to_use)):system/etc/apns-conf.xml
292 endif
293 endif
294endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800295
296ADDITIONAL_BUILD_PROPERTIES += net.bt.name=Android
297
298# enable vm tracing in files for now to help track
299# the cause of ANRs in the content process
300ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.stack-trace-file=/data/anr/traces.txt
301
The Android Open Source Project88b60792009-03-03 19:28:42 -0800302# ------------------------------------------------------------
303# Define a function that, given a list of module tags, returns
304# non-empty if that module should be installed in /system.
305
The Android Open Source Project2f312932009-03-09 11:52:11 -0700306# For most goals, anything not tagged with the "tests" tag should
The Android Open Source Project88b60792009-03-03 19:28:42 -0800307# be installed in /system.
308define should-install-to-system
The Android Open Source Project2f312932009-03-09 11:52:11 -0700309$(if $(filter tests,$(1)),,true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800310endef
311
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700312ifdef is_sdk_build
The Android Open Source Project88b60792009-03-03 19:28:42 -0800313# For the sdk goal, anything with the "samples" tag should be
314# installed in /data even if that module also has "eng"/"debug"/"user".
315define should-install-to-system
The Android Open Source Project2f312932009-03-09 11:52:11 -0700316$(if $(filter samples tests,$(1)),,true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800317endef
318endif
319
320
Joe Onoratoe334d252009-07-17 15:33:40 -0400321# If they only used the modifier goals (showcommands, checkbuild), we'll actually
322# build the default target.
323ifeq ($(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS)),)
324.PHONY: $(INTERNAL_MODIFIER_TARGETS)
325$(INTERNAL_MODIFIER_TARGETS): $(DEFAULT_GOAL)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800326endif
327
328# These targets are going to delete stuff, don't bother including
329# the whole directory tree if that's all we're going to do
330ifeq ($(MAKECMDGOALS),clean)
331dont_bother := true
332endif
333ifeq ($(MAKECMDGOALS),clobber)
334dont_bother := true
335endif
336ifeq ($(MAKECMDGOALS),dataclean)
337dont_bother := true
338endif
339ifeq ($(MAKECMDGOALS),installclean)
340dont_bother := true
341endif
342
343# Bring in all modules that need to be built.
344ifneq ($(dont_bother),true)
345
The Android Open Source Project88b60792009-03-03 19:28:42 -0800346ifeq ($(HOST_OS),windows)
347SDK_ONLY := true
348endif
349ifeq ($(HOST_OS)-$(HOST_ARCH),darwin-ppc)
350SDK_ONLY := true
351endif
352
353ifeq ($(SDK_ONLY),true)
354
Raphael4e7b0e22010-01-12 11:14:17 -0800355# ----- SDK for Windows ------
356# These configure the build targets that are available for the SDK under Cygwin.
357# The first section defines all the C/C++ tools that can be compiled under Cygwin,
358# the second section defines all the Java ones (assuming javac is available.)
359
The Android Open Source Project88b60792009-03-03 19:28:42 -0800360subdirs := \
361 prebuilt \
362 build/libs/host \
Raphael31a8ac22009-08-11 15:36:16 -0700363 build/tools/zipalign \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800364 dalvik/dexdump \
365 dalvik/libdex \
366 dalvik/tools/dmtracedump \
Raphael Molld9b64e12009-03-31 17:20:53 -0700367 dalvik/tools/hprof-conv \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800368 development/tools/line_endings \
Raphael4e7b0e22010-01-12 11:14:17 -0800369 development/tools/etc1tool \
Raphaela62a4422009-11-17 21:20:37 -0800370 sdk/emulator/mksdcard \
371 sdk/sdklauncher \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800372 development/host \
373 external/expat \
374 external/libpng \
375 external/qemu \
376 external/sqlite/dist \
377 external/zlib \
Raphael28fcfdd2009-08-19 14:06:33 -0700378 frameworks/base/libs/utils \
379 frameworks/base/tools/aapt \
380 frameworks/base/tools/aidl \
Raphael4e7b0e22010-01-12 11:14:17 -0800381 frameworks/base/opengl/libs \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800382 system/core/adb \
383 system/core/fastboot \
384 system/core/libcutils \
385 system/core/liblog \
386 system/core/libzipfile
387
388# The following can only be built if "javac" is available.
389# This check is used when building parts of the SDK under Cygwin.
390ifneq (,$(shell which javac 2>/dev/null))
391$(warning sdk-only: javac available.)
392subdirs += \
393 build/tools/signapk \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800394 dalvik/dx \
395 dalvik/libcore \
Raphaela62a4422009-11-17 21:20:37 -0800396 sdk/archquery \
397 sdk/androidprefs \
398 sdk/apkbuilder \
399 sdk/jarutils \
Raphaele749b5a2010-01-22 18:36:37 -0800400 sdk/layoutlib_api \
Raphaela62a4422009-11-17 21:20:37 -0800401 sdk/layoutlib_utils \
402 sdk/ninepatch \
403 sdk/sdkstats \
404 sdk/sdkmanager \
405 sdk/layoutopt \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800406 development/apps \
Raphael Molla779a052009-04-16 10:54:10 -0700407 development/tools/mkstubs \
Raphael28fcfdd2009-08-19 14:06:33 -0700408 frameworks/base/tools/layoutlib \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800409 packages
410else
411$(warning sdk-only: javac not available.)
412endif
413
414# Exclude tools/acp when cross-compiling windows under linux
415ifeq ($(findstring Linux,$(UNAME)),)
416subdirs += build/tools/acp
417endif
418
419else # !SDK_ONLY
420ifeq ($(BUILD_TINY_ANDROID), true)
421
422# TINY_ANDROID is a super-minimal build configuration, handy for board
423# bringup and very low level debugging
424
The Android Open Source Project88b60792009-03-03 19:28:42 -0800425subdirs := \
426 bionic \
427 system/core \
428 build/libs \
429 build/target \
430 build/tools/acp \
431 build/tools/apriori \
432 build/tools/kcm \
433 build/tools/soslim \
434 external/elfcopy \
435 external/elfutils \
436 external/yaffs2 \
437 external/zlib
438else # !BUILD_TINY_ANDROID
439
440#
441# Typical build; include any Android.mk files we can find.
442#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800443subdirs := $(TOP)
444
445FULL_BUILD := true
446
447endif # !BUILD_TINY_ANDROID
448
449endif # !SDK_ONLY
450
The Android Open Source Project88b60792009-03-03 19:28:42 -0800451ifneq ($(ONE_SHOT_MAKEFILE),)
452# We've probably been invoked by the "mm" shell function
453# with a subdirectory's makefile.
454include $(ONE_SHOT_MAKEFILE)
455# Change CUSTOM_MODULES to include only modules that were
456# defined by this makefile; this will install all of those
457# modules as a side-effect. Do this after including ONE_SHOT_MAKEFILE
458# so that the modules will be installed in the same place they
459# would have been with a normal make.
Jean-Baptiste Queru6907cfe2010-01-07 11:19:39 -0800460CUSTOM_MODULES := $(sort $(call get-tagged-modules,$(ALL_MODULE_TAGS)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800461FULL_BUILD :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800462# Stub out the notice targets, which probably aren't defined
463# when using ONE_SHOT_MAKEFILE.
464NOTICE-HOST-%: ;
465NOTICE-TARGET-%: ;
Joe Onoratoead96462009-07-30 11:20:04 -0700466
467else # ONE_SHOT_MAKEFILE
468
469#
470# Include all of the makefiles in the system
471#
472
473# Can't use first-makefiles-under here because
474# --mindepth=2 makes the prunes not work.
475subdir_makefiles := \
Joe Onoratodc1a7282009-08-04 15:58:26 -0400476 $(shell build/tools/findleaves.py --prune=out --prune=.repo --prune=.git $(subdirs) Android.mk)
Joe Onoratoead96462009-07-30 11:20:04 -0700477
The Android Open Source Project88b60792009-03-03 19:28:42 -0800478include $(subdir_makefiles)
Joe Onoratoead96462009-07-30 11:20:04 -0700479endif # ONE_SHOT_MAKEFILE
480
The Android Open Source Project88b60792009-03-03 19:28:42 -0800481# -------------------------------------------------------------------
482# All module makefiles have been included at this point.
483# -------------------------------------------------------------------
484
485# -------------------------------------------------------------------
486# Include any makefiles that must happen after the module makefiles
487# have been included.
488# TODO: have these files register themselves via a global var rather
489# than hard-coding the list here.
490ifdef FULL_BUILD
491 # Only include this during a full build, otherwise we can't be
492 # guaranteed that any policies were included.
493 -include frameworks/policies/base/PolicyConfig.mk
494endif
495
496# -------------------------------------------------------------------
497# Fix up CUSTOM_MODULES to refer to installed files rather than
498# just bare module names. Leave unknown modules alone in case
499# they're actually full paths to a particular file.
500known_custom_modules := $(filter $(ALL_MODULES),$(CUSTOM_MODULES))
501unknown_custom_modules := $(filter-out $(ALL_MODULES),$(CUSTOM_MODULES))
502CUSTOM_MODULES := \
503 $(call module-installed-files,$(known_custom_modules)) \
504 $(unknown_custom_modules)
505
506# -------------------------------------------------------------------
507# Define dependencies for modules that require other modules.
508# This can only happen now, after we've read in all module makefiles.
509#
510# TODO: deal with the fact that a bare module name isn't
511# unambiguous enough. Maybe declare short targets like
512# APPS:Quake or HOST:SHARED_LIBRARIES:libutils.
513# BUG: the system image won't know to depend on modules that are
514# brought in as requirements of other modules.
515define add-required-deps
516$(1): $(2)
517endef
518$(foreach m,$(ALL_MODULES), \
519 $(eval r := $(ALL_MODULES.$(m).REQUIRED)) \
520 $(if $(r), \
521 $(eval r := $(call module-installed-files,$(r))) \
522 $(eval $(call add-required-deps,$(ALL_MODULES.$(m).INSTALLED),$(r))) \
523 ) \
524 )
525m :=
526r :=
527add-required-deps :=
528
529# -------------------------------------------------------------------
530# Figure out our module sets.
531
532# Of the modules defined by the component makefiles,
533# determine what we actually want to build.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800534Default_MODULES := $(sort $(ALL_DEFAULT_INSTALLED_MODULES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800535 $(CUSTOM_MODULES))
The Android Open Source Project2f312932009-03-09 11:52:11 -0700536# TODO: Remove the 3 places in the tree that use
537# ALL_DEFAULT_INSTALLED_MODULES and get rid of it from this list.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800538
539ifdef FULL_BUILD
540 # The base list of modules to build for this product is specified
541 # by the appropriate product definition file, which was included
542 # by product_config.make.
543 user_PACKAGES := $(call module-installed-files, \
544 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES))
545 ifeq (0,1)
546 $(info user packages for $(TARGET_DEVICE) ($(INTERNAL_PRODUCT)):)
547 $(foreach p,$(user_PACKAGES),$(info : $(p)))
548 $(error done)
549 endif
550else
551 # We're not doing a full build, and are probably only including
552 # a subset of the module makefiles. Don't try to build any modules
553 # requested by the product, because we probably won't have rules
554 # to build them.
555 user_PACKAGES :=
556endif
557# Use tags to get the non-APPS user modules. Use the product
558# definition files to get the APPS user modules.
Jean-Baptiste Queru75127b72010-01-07 11:44:22 -0800559user_MODULES := $(sort $(call get-tagged-modules,user))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800560user_MODULES := $(user_MODULES) $(user_PACKAGES)
561
Jean-Baptiste Queru75127b72010-01-07 11:44:22 -0800562eng_MODULES := $(sort $(call get-tagged-modules,eng))
563debug_MODULES := $(sort $(call get-tagged-modules,debug))
564tests_MODULES := $(sort $(call get-tagged-modules,tests))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800565
The Android Open Source Project2f312932009-03-09 11:52:11 -0700566ifeq ($(strip $(tags_to_install)),)
567$(error ASSERTION FAILED: tags_to_install should not be empty)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800568endif
The Android Open Source Project2f312932009-03-09 11:52:11 -0700569modules_to_install := $(sort $(Default_MODULES) \
570 $(foreach tag,$(tags_to_install),$($(tag)_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800571
572# Some packages may override others using LOCAL_OVERRIDES_PACKAGES.
573# Filter out (do not install) any overridden packages.
The Android Open Source Project2f312932009-03-09 11:52:11 -0700574overridden_packages := $(call get-package-overrides,$(modules_to_install))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800575ifdef overridden_packages
The Android Open Source Project2f312932009-03-09 11:52:11 -0700576# old_modules_to_install := $(modules_to_install)
577 modules_to_install := \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800578 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \
The Android Open Source Project2f312932009-03-09 11:52:11 -0700579 $(modules_to_install))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800580endif
The Android Open Source Project2f312932009-03-09 11:52:11 -0700581#$(error filtered out
582# $(filter-out $(modules_to_install),$(old_modules_to_install)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800583
584# Don't include any GNU targets in the SDK. It's ok (and necessary)
585# to build the host tools, but nothing that's going to be installed
586# on the target (including static libraries).
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700587ifdef is_sdk_build
The Android Open Source Project88b60792009-03-03 19:28:42 -0800588 target_gnu_MODULES := \
589 $(filter \
590 $(TARGET_OUT_INTERMEDIATES)/% \
591 $(TARGET_OUT)/% \
592 $(TARGET_OUT_DATA)/%, \
593 $(sort $(call get-tagged-modules,gnu)))
594 $(info Removing from sdk:)$(foreach d,$(target_gnu_MODULES),$(info : $(d)))
The Android Open Source Project2f312932009-03-09 11:52:11 -0700595 modules_to_install := \
596 $(filter-out $(target_gnu_MODULES),$(modules_to_install))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800597endif
598
599
Joe Onoratoe334d252009-07-17 15:33:40 -0400600# build/core/Makefile contains extra stuff that we don't want to pollute this
The Android Open Source Project88b60792009-03-03 19:28:42 -0800601# top-level makefile with. It expects that ALL_DEFAULT_INSTALLED_MODULES
602# contains everything that's built during the current make, but it also further
603# extends ALL_DEFAULT_INSTALLED_MODULES.
The Android Open Source Project2f312932009-03-09 11:52:11 -0700604ALL_DEFAULT_INSTALLED_MODULES := $(modules_to_install)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800605include $(BUILD_SYSTEM)/Makefile
The Android Open Source Project2f312932009-03-09 11:52:11 -0700606modules_to_install := $(sort $(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800607ALL_DEFAULT_INSTALLED_MODULES :=
608
609endif # dont_bother
610
Joe Onoratoe334d252009-07-17 15:33:40 -0400611# These are additional goals that we build, in order to make sure that there
612# is as little code as possible in the tree that doesn't build.
613modules_to_check := $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).CHECKED))
614
615# If you would like to build all goals, and not skip any intermediate
616# steps, you can pass the "all" modifier goal on the commandline.
617ifneq ($(filter all,$(MAKECMDGOALS)),)
618modules_to_check += $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).BUILT))
619endif
620
621# for easier debugging
622modules_to_check := $(sort $(modules_to_check))
623#$(error modules_to_check $(modules_to_check))
624
The Android Open Source Project88b60792009-03-03 19:28:42 -0800625# -------------------------------------------------------------------
626# This is used to to get the ordering right, you can also use these,
627# but they're considered undocumented, so don't complain if their
628# behavior changes.
629.PHONY: prebuilt
630prebuilt: $(ALL_PREBUILT)
631
632# An internal target that depends on all copied headers
633# (see copy_headers.make). Other targets that need the
634# headers to be copied first can depend on this target.
635.PHONY: all_copied_headers
636all_copied_headers: ;
637
638$(ALL_C_CPP_ETC_OBJECTS): | all_copied_headers
639
640# All the droid stuff, in directories
641.PHONY: files
Joe Onoratoe334d252009-07-17 15:33:40 -0400642files: prebuilt \
643 $(modules_to_install) \
644 $(modules_to_check) \
645 $(INSTALLED_ANDROID_INFO_TXT_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800646
647# -------------------------------------------------------------------
648
Joe Onoratoe334d252009-07-17 15:33:40 -0400649.PHONY: checkbuild
650checkbuild: $(modules_to_check)
651
The Android Open Source Project88b60792009-03-03 19:28:42 -0800652.PHONY: ramdisk
653ramdisk: $(INSTALLED_RAMDISK_TARGET)
654
655.PHONY: systemtarball
656systemtarball: $(INSTALLED_SYSTEMTARBALL_TARGET)
657
658.PHONY: userdataimage
659userdataimage: $(INSTALLED_USERDATAIMAGE_TARGET)
660
661.PHONY: userdatatarball
662userdatatarball: $(INSTALLED_USERDATATARBALL_TARGET)
663
664.PHONY: bootimage
665bootimage: $(INSTALLED_BOOTIMAGE_TARGET)
666
667ifeq ($(BUILD_TINY_ANDROID), true)
668INSTALLED_RECOVERYIMAGE_TARGET :=
669endif
670
671# Build files and then package it into the rom formats
672.PHONY: droidcore
673droidcore: files \
674 systemimage \
675 $(INSTALLED_BOOTIMAGE_TARGET) \
676 $(INSTALLED_RECOVERYIMAGE_TARGET) \
677 $(INSTALLED_USERDATAIMAGE_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800678 $(INSTALLED_FILES_FILE)
679
680# The actual files built by the droidcore target changes depending
681# on the build variant.
682.PHONY: droid tests
683droid tests: droidcore
684
685$(call dist-for-goals, droid, \
686 $(INTERNAL_UPDATE_PACKAGE_TARGET) \
687 $(INTERNAL_OTA_PACKAGE_TARGET) \
688 $(SYMBOLS_ZIP) \
689 $(APPS_ZIP) \
690 $(INTERNAL_EMULATOR_PACKAGE_TARGET) \
691 $(PACKAGE_STATS_FILE) \
692 $(INSTALLED_FILES_FILE) \
693 $(INSTALLED_BUILD_PROP_TARGET) \
694 $(BUILT_TARGET_FILES_PACKAGE) \
Ying Wang9a6a1e32010-03-17 17:07:39 -0700695 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800696 )
697
698# Tests are installed in userdata.img. If we're building the tests
699# variant, copy it for "make tests dist". Also copy a zip of the
700# contents of userdata.img, so that people can easily extract a
701# single .apk.
702ifeq ($(TARGET_BUILD_VARIANT),tests)
703$(call dist-for-goals, droid, \
704 $(INSTALLED_USERDATAIMAGE_TARGET) \
705 $(BUILT_TESTS_ZIP_PACKAGE) \
706 )
707endif
708
709.PHONY: docs
710docs: $(ALL_DOCS)
711
712.PHONY: sdk
713ALL_SDK_TARGETS := $(INTERNAL_SDK_TARGET)
714sdk: $(ALL_SDK_TARGETS)
715$(call dist-for-goals,sdk,$(ALL_SDK_TARGETS))
716
717.PHONY: findbugs
718findbugs: $(INTERNAL_FINDBUGS_HTML_TARGET) $(INTERNAL_FINDBUGS_XML_TARGET)
719
720.PHONY: clean
721dirs_to_clean := \
722 $(PRODUCT_OUT) \
723 $(TARGET_COMMON_OUT_ROOT) \
724 $(HOST_OUT) \
725 $(HOST_COMMON_OUT_ROOT)
726clean:
727 @for dir in $(dirs_to_clean) ; do \
728 echo "Cleaning $$dir..."; \
729 rm -rf $$dir; \
730 done
731 @echo "Clean."; \
732
733.PHONY: clobber
734clobber:
735 @rm -rf $(OUT_DIR)
736 @echo "Entire build directory removed."
737
738# The rules for dataclean and installclean are defined in cleanbuild.mk.
739
740#xxx scrape this from ALL_MODULE_NAME_TAGS
741.PHONY: modules
742modules:
743 @echo "Available sub-modules:"
744 @echo "$(call module-names-for-tag-list,$(ALL_MODULE_TAGS))" | \
745 sed -e 's/ */\n/g' | sort -u | $(COLUMN)
746
747.PHONY: showcommands
748showcommands:
749 @echo >/dev/null