blob: b1a5bff1d157fdb97312f9ea47419a358083e6c0 [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001
2# Use bash, not whatever shell somebody has installed as /bin/sh
3# This is repeated in config.mk, since envsetup.sh runs that file
4# directly.
5SHELL := /bin/bash
6
7# this turns off the suffix rules built into make
8.SUFFIXES:
9
10# If a rule fails, delete $@.
11.DELETE_ON_ERROR:
12
13# Figure out where we are.
14#TOP := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
15#TOP := $(patsubst %/,%,$(TOP))
16
17# TOPDIR is the normal variable you should use, because
18# if we are executing relative to the current directory
19# it can be "", whereas TOP must be "." which causes
20# pattern matching probles when make strips off the
21# trailing "./" from paths in various places.
22#ifeq ($(TOP),.)
23#TOPDIR :=
24#else
25#TOPDIR := $(TOP)/
26#endif
27
28# check for broken versions of make
29ifeq (0,$(shell expr $$(echo $(MAKE_VERSION) | sed "s/[^0-9\.].*//") \>= 3.81))
30$(warning ********************************************************************************)
31$(warning * You are using version $(MAKE_VERSION) of make.)
32$(warning * You must upgrade to version 3.81 or greater.)
33$(warning * see file://$(shell pwd)/docs/development-environment/machine-setup.html)
34$(warning ********************************************************************************)
35$(error stopping)
36endif
37
38TOP := .
39TOPDIR :=
40
41BUILD_SYSTEM := $(TOPDIR)build/core
42
43# This is the default target. It must be the first declared target.
44DEFAULT_GOAL := droid
45$(DEFAULT_GOAL):
46
47# Set up various standard variables based on configuration
48# and host information.
49include $(BUILD_SYSTEM)/config.mk
50
51# This allows us to force a clean build - included after the config.make
52# environment setup is done, but before we generate any dependencies. This
53# file does the rm -rf inline so the deps which are all done below will
54# be generated correctly
55include $(BUILD_SYSTEM)/cleanbuild.mk
56
Joe Onorato1de66882009-07-30 11:54:27 -070057VERSION_CHECK_SEQUENCE_NUMBER := 1
58-include $(OUT_DIR)/versions_checked.mk
59ifneq ($(VERSION_CHECK_SEQUENCE_NUMBER),$(VERSIONS_CHECKED))
60
61$(info Checking build tools versions...)
62
The Android Open Source Project88b60792009-03-03 19:28:42 -080063ifneq ($(HOST_OS),windows)
64ifneq ($(HOST_OS)-$(HOST_ARCH),darwin-ppc)
65# check for a case sensitive file system
66ifneq (a,$(shell mkdir -p $(OUT_DIR) ; \
67 echo a > $(OUT_DIR)/casecheck.txt; \
68 echo B > $(OUT_DIR)/CaseCheck.txt; \
69 cat $(OUT_DIR)/casecheck.txt))
70$(warning ************************************************************)
71$(warning You are building on a case-insensitive filesystem.)
72$(warning Please move your source tree to a case-sensitive filesystem.)
73$(warning ************************************************************)
74$(error Case-insensitive filesystems not supported)
75endif
76endif
77endif
78
79# Make sure that there are no spaces in the absolute path; the
80# build system can't deal with them.
81ifneq ($(words $(shell pwd)),1)
82$(warning ************************************************************)
83$(warning You are building in a directory whose absolute path contains)
84$(warning a space character:)
85$(warning $(space))
86$(warning "$(shell pwd)")
87$(warning $(space))
88$(warning Please move your source tree to a path that does not contain)
89$(warning any spaces.)
90$(warning ************************************************************)
91$(error Directory names containing spaces not supported)
92endif
93
Joe Onorato9d9f3672009-06-22 18:15:38 -070094
95# The windows build server currently uses 1.6. This will be fixed.
96ifneq ($(HOST_OS),windows)
97
98# Check for the correct version of java
99java_version := $(shell java -version 2>&1 | head -n 1 | grep '[ "]1\.5[\. "$$]')
100ifeq ($(strip $(java_version)),)
101$(info ************************************************************)
102$(info You are attempting to build with the incorrect version)
103$(info of java.)
104$(info $(space))
105$(info Your version is: $(shell java -version 2>&1 | head -n 1).)
106$(info The correct version is: 1.5.)
107$(info $(space))
108$(info Please follow the machine setup instructions at)
109$(info $(space)$(space)$(space)$(space)http://source.android.com/download)
110$(info ************************************************************)
111$(error stop)
112endif
113
114# Check for the correct version of javac
115javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1\.5[\. "$$]')
116ifeq ($(strip $(javac_version)),)
117$(info ************************************************************)
118$(info You are attempting to build with the incorrect version)
119$(info of javac.)
120$(info $(space))
121$(info Your version is: $(shell javac -version 2>&1 | head -n 1).)
122$(info The correct version is: 1.5.)
123$(info $(space))
124$(info Please follow the machine setup instructions at)
125$(info $(space)$(space)$(space)$(space)http://source.android.com/download)
126$(info ************************************************************)
127$(error stop)
128endif
129
130endif # windows
131
Joe Onorato1de66882009-07-30 11:54:27 -0700132$(shell echo 'VERSIONS_CHECKED := $(VERSION_CHECK_SEQUENCE_NUMBER)' \
133 > $(OUT_DIR)/versions_checked.mk)
134endif
135
The Android Open Source Project88b60792009-03-03 19:28:42 -0800136# These are the modifier targets that don't do anything themselves, but
137# change the behavior of the build.
138# (must be defined before including definitions.make)
Joe Onoratoe334d252009-07-17 15:33:40 -0400139INTERNAL_MODIFIER_TARGETS := showcommands checkbuild
The Android Open Source Project88b60792009-03-03 19:28:42 -0800140
141# Bring in standard build system definitions.
142include $(BUILD_SYSTEM)/definitions.mk
143
144ifneq ($(filter eng user userdebug tests,$(MAKECMDGOALS)),)
145$(info ***************************************************************)
146$(info ***************************************************************)
147$(info Don't pass '$(filter eng user userdebug tests,$(MAKECMDGOALS))' on \
148 the make command line.)
The Android Open Source Project2f312932009-03-09 11:52:11 -0700149# XXX The single quote on this line fixes gvim's syntax highlighting.
150# Without which, the rest of this file is impossible to read.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800151$(info Set TARGET_BUILD_VARIANT in buildspec.mk, or use lunch or)
152$(info choosecombo.)
153$(info ***************************************************************)
154$(info ***************************************************************)
155$(error stopping)
156endif
157
The Android Open Source Project2f312932009-03-09 11:52:11 -0700158ifneq ($(filter-out $(INTERNAL_VALID_VARIANTS),$(TARGET_BUILD_VARIANT)),)
159$(info ***************************************************************)
160$(info ***************************************************************)
161$(info Invalid variant: $(TARGET_BUILD_VARIANT)
162$(info Valid values are: $(INTERNAL_VALID_VARIANTS)
163$(info ***************************************************************)
164$(info ***************************************************************)
165$(error stopping)
166endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800167
168###
169### In this section we set up the things that are different
170### between the build variants
171###
172
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700173is_sdk_build :=
174ifneq ($(filter sdk,$(MAKECMDGOALS)),)
175is_sdk_build := true
176endif
177ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),)
178is_sdk_build := true
179endif
180
181
The Android Open Source Project88b60792009-03-03 19:28:42 -0800182## user/userdebug ##
183
184user_variant := $(filter userdebug user,$(TARGET_BUILD_VARIANT))
185enable_target_debugging := true
186ifneq (,$(user_variant))
187 # Target is secure in user builds.
188 ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=1
189
The Android Open Source Project2f312932009-03-09 11:52:11 -0700190 tags_to_install := user
The Android Open Source Project88b60792009-03-03 19:28:42 -0800191 ifeq ($(user_variant),userdebug)
192 # Pick up some extra useful tools
The Android Open Source Project2f312932009-03-09 11:52:11 -0700193 tags_to_install += debug
The Android Open Source Project88b60792009-03-03 19:28:42 -0800194 else
195 # Disable debugging in plain user builds.
196 enable_target_debugging :=
197 endif
198
199 # TODO: Always set WITH_DEXPREOPT (for user builds) once it works on OSX.
200 # Also, remove the corresponding block in config/product_config.make.
201 ifeq ($(HOST_OS)-$(WITH_DEXPREOPT_buildbot),linux-true)
202 WITH_DEXPREOPT := true
203 endif
204
205 # Disallow mock locations by default for user builds
206 ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=0
207
208else # !user_variant
209 # Turn on checkjni for non-user builds.
210 ADDITIONAL_BUILD_PROPERTIES += ro.kernel.android.checkjni=1
211 # Set device insecure for non-user builds.
212 ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0
213 # Allow mock locations by default for non user builds
214 ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=1
215endif # !user_variant
216
217ifeq (true,$(strip $(enable_target_debugging)))
218 # Target is more debuggable and adbd is on by default
219 ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1 persist.service.adb.enable=1
220 # Include the debugging/testing OTA keys in this build.
221 INCLUDE_TEST_OTA_KEYS := true
222else # !enable_target_debugging
223 # Target is less debuggable and adbd is off by default
224 ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0 persist.service.adb.enable=0
225endif # !enable_target_debugging
226
The Android Open Source Project2f312932009-03-09 11:52:11 -0700227## eng ##
228
229ifeq ($(TARGET_BUILD_VARIANT),eng)
230tags_to_install := user debug eng
The Android Open Source Projectfdd3a102009-03-11 12:11:54 -0700231 # Don't require the setup wizard on eng builds
232 ADDITIONAL_BUILD_PROPERTIES := $(filter-out ro.setupwizard.mode=%,\
Joe Onorato08896612009-10-07 10:01:13 -0700233 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))) \
234 ro.setupwizard.mode=OPTIONAL
The Android Open Source Project2f312932009-03-09 11:52:11 -0700235endif
236
The Android Open Source Project88b60792009-03-03 19:28:42 -0800237## tests ##
238
239ifeq ($(TARGET_BUILD_VARIANT),tests)
The Android Open Source Project2f312932009-03-09 11:52:11 -0700240tags_to_install := user debug eng tests
The Android Open Source Project88b60792009-03-03 19:28:42 -0800241endif
242
243## sdk ##
244
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700245ifdef is_sdk_build
The Android Open Source Project88b60792009-03-03 19:28:42 -0800246ifneq ($(words $(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS))),1)
247$(error The 'sdk' target may not be specified with any other targets)
248endif
The Android Open Source Project2f312932009-03-09 11:52:11 -0700249# TODO: this should be eng I think. Since the sdk is built from the eng
250# variant.
Xavier Ducrohetf3e79f92009-04-06 20:32:24 -0700251tags_to_install := user debug eng
The Android Open Source Project88b60792009-03-03 19:28:42 -0800252ADDITIONAL_BUILD_PROPERTIES += xmpp.auto-presence=true
253ADDITIONAL_BUILD_PROPERTIES += ro.config.nocheckin=yes
254else # !sdk
The Android Open Source Project88b60792009-03-03 19:28:42 -0800255endif
256
Andreas Huber64b00e32009-12-17 14:03:12 -0800257# build the full stagefright library
258ifneq ($(strip BUILD_WITH_FULL_STAGEFRIGHT),)
259BUILD_WITH_FULL_STAGEFRIGHT := true
260endif
261
Andy McFadden743e2502009-04-13 14:48:35 -0700262## precise GC ##
263
264ifneq ($(filter dalvik.gc.type-precise,$(PRODUCT_TAGS)),)
265 # Enabling type-precise GC results in larger optimized DEX files. The
266 # additional storage requirements for ".odex" files can cause /system
267 # to overflow on some devices, so this is configured separately for
268 # each product.
269 ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.dexopt-flags=m=y
270endif
271
The Android Open Source Project6bce2052009-03-13 13:04:19 -0700272# Install an apns-conf.xml file if one's not already being installed.
273ifeq (,$(filter %:system/etc/apns-conf.xml, $(PRODUCT_COPY_FILES)))
274 PRODUCT_COPY_FILES += \
275 development/data/etc/apns-conf_sdk.xml:system/etc/apns-conf.xml
276 ifeq ($(filter eng tests,$(TARGET_BUILD_VARIANT)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800277 $(warning implicitly installing apns-conf_sdk.xml)
278 endif
279endif
The Android Open Source Project6bce2052009-03-13 13:04:19 -0700280# If we're on an eng or tests build, but not on the sdk, and we have
281# a better one, use that instead.
282ifneq ($(filter eng tests,$(TARGET_BUILD_VARIANT)),)
Patrick Scott1f04a3b2009-06-09 10:34:45 -0400283 ifndef is_sdk_build
The Android Open Source Project6bce2052009-03-13 13:04:19 -0700284 apns_to_use := $(wildcard vendor/google/etc/apns-conf.xml)
285 ifneq ($(strip $(apns_to_use)),)
286 PRODUCT_COPY_FILES := \
287 $(filter-out %:system/etc/apns-conf.xml,$(PRODUCT_COPY_FILES)) \
288 $(strip $(apns_to_use)):system/etc/apns-conf.xml
289 endif
290 endif
291endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800292
293ADDITIONAL_BUILD_PROPERTIES += net.bt.name=Android
294
295# enable vm tracing in files for now to help track
296# the cause of ANRs in the content process
297ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.stack-trace-file=/data/anr/traces.txt
298
The Android Open Source Project88b60792009-03-03 19:28:42 -0800299# ------------------------------------------------------------
300# Define a function that, given a list of module tags, returns
301# non-empty if that module should be installed in /system.
302
The Android Open Source Project2f312932009-03-09 11:52:11 -0700303# For most goals, anything not tagged with the "tests" tag should
The Android Open Source Project88b60792009-03-03 19:28:42 -0800304# be installed in /system.
305define should-install-to-system
The Android Open Source Project2f312932009-03-09 11:52:11 -0700306$(if $(filter tests,$(1)),,true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800307endef
308
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700309ifdef is_sdk_build
The Android Open Source Project88b60792009-03-03 19:28:42 -0800310# For the sdk goal, anything with the "samples" tag should be
311# installed in /data even if that module also has "eng"/"debug"/"user".
312define should-install-to-system
The Android Open Source Project2f312932009-03-09 11:52:11 -0700313$(if $(filter samples tests,$(1)),,true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800314endef
315endif
316
317
Joe Onoratoe334d252009-07-17 15:33:40 -0400318# If they only used the modifier goals (showcommands, checkbuild), we'll actually
319# build the default target.
320ifeq ($(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS)),)
321.PHONY: $(INTERNAL_MODIFIER_TARGETS)
322$(INTERNAL_MODIFIER_TARGETS): $(DEFAULT_GOAL)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800323endif
324
325# These targets are going to delete stuff, don't bother including
326# the whole directory tree if that's all we're going to do
327ifeq ($(MAKECMDGOALS),clean)
328dont_bother := true
329endif
330ifeq ($(MAKECMDGOALS),clobber)
331dont_bother := true
332endif
333ifeq ($(MAKECMDGOALS),dataclean)
334dont_bother := true
335endif
336ifeq ($(MAKECMDGOALS),installclean)
337dont_bother := true
338endif
339
340# Bring in all modules that need to be built.
341ifneq ($(dont_bother),true)
342
The Android Open Source Project88b60792009-03-03 19:28:42 -0800343ifeq ($(HOST_OS),windows)
344SDK_ONLY := true
345endif
346ifeq ($(HOST_OS)-$(HOST_ARCH),darwin-ppc)
347SDK_ONLY := true
348endif
349
350ifeq ($(SDK_ONLY),true)
351
Raphael4e7b0e22010-01-12 11:14:17 -0800352# ----- SDK for Windows ------
353# These configure the build targets that are available for the SDK under Cygwin.
354# The first section defines all the C/C++ tools that can be compiled under Cygwin,
355# the second section defines all the Java ones (assuming javac is available.)
356
The Android Open Source Project88b60792009-03-03 19:28:42 -0800357subdirs := \
358 prebuilt \
359 build/libs/host \
Raphael31a8ac22009-08-11 15:36:16 -0700360 build/tools/zipalign \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800361 dalvik/dexdump \
362 dalvik/libdex \
363 dalvik/tools/dmtracedump \
Raphael Molld9b64e12009-03-31 17:20:53 -0700364 dalvik/tools/hprof-conv \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800365 development/tools/line_endings \
Raphael4e7b0e22010-01-12 11:14:17 -0800366 development/tools/etc1tool \
Raphaela62a4422009-11-17 21:20:37 -0800367 sdk/emulator/mksdcard \
368 sdk/sdklauncher \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800369 development/host \
370 external/expat \
371 external/libpng \
372 external/qemu \
373 external/sqlite/dist \
374 external/zlib \
Raphael28fcfdd2009-08-19 14:06:33 -0700375 frameworks/base/libs/utils \
376 frameworks/base/tools/aapt \
377 frameworks/base/tools/aidl \
Raphael4e7b0e22010-01-12 11:14:17 -0800378 frameworks/base/opengl/libs \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800379 system/core/adb \
380 system/core/fastboot \
381 system/core/libcutils \
382 system/core/liblog \
383 system/core/libzipfile
384
385# The following can only be built if "javac" is available.
386# This check is used when building parts of the SDK under Cygwin.
387ifneq (,$(shell which javac 2>/dev/null))
388$(warning sdk-only: javac available.)
389subdirs += \
390 build/tools/signapk \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800391 dalvik/dx \
392 dalvik/libcore \
Raphaela62a4422009-11-17 21:20:37 -0800393 sdk/archquery \
394 sdk/androidprefs \
395 sdk/apkbuilder \
396 sdk/jarutils \
Raphaele749b5a2010-01-22 18:36:37 -0800397 sdk/layoutlib_api \
Raphaela62a4422009-11-17 21:20:37 -0800398 sdk/layoutlib_utils \
399 sdk/ninepatch \
400 sdk/sdkstats \
401 sdk/sdkmanager \
402 sdk/layoutopt \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800403 development/apps \
Raphael Molla779a052009-04-16 10:54:10 -0700404 development/tools/mkstubs \
Raphael28fcfdd2009-08-19 14:06:33 -0700405 frameworks/base/tools/layoutlib \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800406 packages
407else
408$(warning sdk-only: javac not available.)
409endif
410
411# Exclude tools/acp when cross-compiling windows under linux
412ifeq ($(findstring Linux,$(UNAME)),)
413subdirs += build/tools/acp
414endif
415
416else # !SDK_ONLY
417ifeq ($(BUILD_TINY_ANDROID), true)
418
419# TINY_ANDROID is a super-minimal build configuration, handy for board
420# bringup and very low level debugging
421
The Android Open Source Project88b60792009-03-03 19:28:42 -0800422subdirs := \
423 bionic \
424 system/core \
425 build/libs \
426 build/target \
427 build/tools/acp \
428 build/tools/apriori \
429 build/tools/kcm \
430 build/tools/soslim \
431 external/elfcopy \
432 external/elfutils \
433 external/yaffs2 \
434 external/zlib
435else # !BUILD_TINY_ANDROID
436
437#
438# Typical build; include any Android.mk files we can find.
439#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800440subdirs := $(TOP)
441
442FULL_BUILD := true
443
444endif # !BUILD_TINY_ANDROID
445
446endif # !SDK_ONLY
447
The Android Open Source Project88b60792009-03-03 19:28:42 -0800448ifneq ($(ONE_SHOT_MAKEFILE),)
449# We've probably been invoked by the "mm" shell function
450# with a subdirectory's makefile.
451include $(ONE_SHOT_MAKEFILE)
452# Change CUSTOM_MODULES to include only modules that were
453# defined by this makefile; this will install all of those
454# modules as a side-effect. Do this after including ONE_SHOT_MAKEFILE
455# so that the modules will be installed in the same place they
456# would have been with a normal make.
Jean-Baptiste Queru6907cfe2010-01-07 11:19:39 -0800457CUSTOM_MODULES := $(sort $(call get-tagged-modules,$(ALL_MODULE_TAGS)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800458FULL_BUILD :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800459# Stub out the notice targets, which probably aren't defined
460# when using ONE_SHOT_MAKEFILE.
461NOTICE-HOST-%: ;
462NOTICE-TARGET-%: ;
Joe Onoratoead96462009-07-30 11:20:04 -0700463
464else # ONE_SHOT_MAKEFILE
465
466#
467# Include all of the makefiles in the system
468#
469
470# Can't use first-makefiles-under here because
471# --mindepth=2 makes the prunes not work.
472subdir_makefiles := \
Joe Onoratodc1a7282009-08-04 15:58:26 -0400473 $(shell build/tools/findleaves.py --prune=out --prune=.repo --prune=.git $(subdirs) Android.mk)
Joe Onoratoead96462009-07-30 11:20:04 -0700474
The Android Open Source Project88b60792009-03-03 19:28:42 -0800475include $(subdir_makefiles)
Joe Onoratoead96462009-07-30 11:20:04 -0700476endif # ONE_SHOT_MAKEFILE
477
The Android Open Source Project88b60792009-03-03 19:28:42 -0800478# -------------------------------------------------------------------
479# All module makefiles have been included at this point.
480# -------------------------------------------------------------------
481
482# -------------------------------------------------------------------
483# Include any makefiles that must happen after the module makefiles
484# have been included.
485# TODO: have these files register themselves via a global var rather
486# than hard-coding the list here.
487ifdef FULL_BUILD
488 # Only include this during a full build, otherwise we can't be
489 # guaranteed that any policies were included.
490 -include frameworks/policies/base/PolicyConfig.mk
491endif
492
493# -------------------------------------------------------------------
494# Fix up CUSTOM_MODULES to refer to installed files rather than
495# just bare module names. Leave unknown modules alone in case
496# they're actually full paths to a particular file.
497known_custom_modules := $(filter $(ALL_MODULES),$(CUSTOM_MODULES))
498unknown_custom_modules := $(filter-out $(ALL_MODULES),$(CUSTOM_MODULES))
499CUSTOM_MODULES := \
500 $(call module-installed-files,$(known_custom_modules)) \
501 $(unknown_custom_modules)
502
503# -------------------------------------------------------------------
504# Define dependencies for modules that require other modules.
505# This can only happen now, after we've read in all module makefiles.
506#
507# TODO: deal with the fact that a bare module name isn't
508# unambiguous enough. Maybe declare short targets like
509# APPS:Quake or HOST:SHARED_LIBRARIES:libutils.
510# BUG: the system image won't know to depend on modules that are
511# brought in as requirements of other modules.
512define add-required-deps
513$(1): $(2)
514endef
515$(foreach m,$(ALL_MODULES), \
516 $(eval r := $(ALL_MODULES.$(m).REQUIRED)) \
517 $(if $(r), \
518 $(eval r := $(call module-installed-files,$(r))) \
519 $(eval $(call add-required-deps,$(ALL_MODULES.$(m).INSTALLED),$(r))) \
520 ) \
521 )
522m :=
523r :=
524add-required-deps :=
525
526# -------------------------------------------------------------------
527# Figure out our module sets.
528
529# Of the modules defined by the component makefiles,
530# determine what we actually want to build.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800531Default_MODULES := $(sort $(ALL_DEFAULT_INSTALLED_MODULES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800532 $(CUSTOM_MODULES))
The Android Open Source Project2f312932009-03-09 11:52:11 -0700533# TODO: Remove the 3 places in the tree that use
534# ALL_DEFAULT_INSTALLED_MODULES and get rid of it from this list.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800535
536ifdef FULL_BUILD
537 # The base list of modules to build for this product is specified
538 # by the appropriate product definition file, which was included
539 # by product_config.make.
540 user_PACKAGES := $(call module-installed-files, \
541 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES))
542 ifeq (0,1)
543 $(info user packages for $(TARGET_DEVICE) ($(INTERNAL_PRODUCT)):)
544 $(foreach p,$(user_PACKAGES),$(info : $(p)))
545 $(error done)
546 endif
547else
548 # We're not doing a full build, and are probably only including
549 # a subset of the module makefiles. Don't try to build any modules
550 # requested by the product, because we probably won't have rules
551 # to build them.
552 user_PACKAGES :=
553endif
554# Use tags to get the non-APPS user modules. Use the product
555# definition files to get the APPS user modules.
Jean-Baptiste Queru75127b72010-01-07 11:44:22 -0800556user_MODULES := $(sort $(call get-tagged-modules,user))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800557user_MODULES := $(user_MODULES) $(user_PACKAGES)
558
Jean-Baptiste Queru75127b72010-01-07 11:44:22 -0800559eng_MODULES := $(sort $(call get-tagged-modules,eng))
560debug_MODULES := $(sort $(call get-tagged-modules,debug))
561tests_MODULES := $(sort $(call get-tagged-modules,tests))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800562
The Android Open Source Project2f312932009-03-09 11:52:11 -0700563ifeq ($(strip $(tags_to_install)),)
564$(error ASSERTION FAILED: tags_to_install should not be empty)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800565endif
The Android Open Source Project2f312932009-03-09 11:52:11 -0700566modules_to_install := $(sort $(Default_MODULES) \
567 $(foreach tag,$(tags_to_install),$($(tag)_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800568
569# Some packages may override others using LOCAL_OVERRIDES_PACKAGES.
570# Filter out (do not install) any overridden packages.
The Android Open Source Project2f312932009-03-09 11:52:11 -0700571overridden_packages := $(call get-package-overrides,$(modules_to_install))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800572ifdef overridden_packages
The Android Open Source Project2f312932009-03-09 11:52:11 -0700573# old_modules_to_install := $(modules_to_install)
574 modules_to_install := \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800575 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \
The Android Open Source Project2f312932009-03-09 11:52:11 -0700576 $(modules_to_install))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800577endif
The Android Open Source Project2f312932009-03-09 11:52:11 -0700578#$(error filtered out
579# $(filter-out $(modules_to_install),$(old_modules_to_install)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800580
581# Don't include any GNU targets in the SDK. It's ok (and necessary)
582# to build the host tools, but nothing that's going to be installed
583# on the target (including static libraries).
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700584ifdef is_sdk_build
The Android Open Source Project88b60792009-03-03 19:28:42 -0800585 target_gnu_MODULES := \
586 $(filter \
587 $(TARGET_OUT_INTERMEDIATES)/% \
588 $(TARGET_OUT)/% \
589 $(TARGET_OUT_DATA)/%, \
590 $(sort $(call get-tagged-modules,gnu)))
591 $(info Removing from sdk:)$(foreach d,$(target_gnu_MODULES),$(info : $(d)))
The Android Open Source Project2f312932009-03-09 11:52:11 -0700592 modules_to_install := \
593 $(filter-out $(target_gnu_MODULES),$(modules_to_install))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800594endif
595
596
Joe Onoratoe334d252009-07-17 15:33:40 -0400597# build/core/Makefile contains extra stuff that we don't want to pollute this
The Android Open Source Project88b60792009-03-03 19:28:42 -0800598# top-level makefile with. It expects that ALL_DEFAULT_INSTALLED_MODULES
599# contains everything that's built during the current make, but it also further
600# extends ALL_DEFAULT_INSTALLED_MODULES.
The Android Open Source Project2f312932009-03-09 11:52:11 -0700601ALL_DEFAULT_INSTALLED_MODULES := $(modules_to_install)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800602include $(BUILD_SYSTEM)/Makefile
The Android Open Source Project2f312932009-03-09 11:52:11 -0700603modules_to_install := $(sort $(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800604ALL_DEFAULT_INSTALLED_MODULES :=
605
606endif # dont_bother
607
Joe Onoratoe334d252009-07-17 15:33:40 -0400608# These are additional goals that we build, in order to make sure that there
609# is as little code as possible in the tree that doesn't build.
610modules_to_check := $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).CHECKED))
611
612# If you would like to build all goals, and not skip any intermediate
613# steps, you can pass the "all" modifier goal on the commandline.
614ifneq ($(filter all,$(MAKECMDGOALS)),)
615modules_to_check += $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).BUILT))
616endif
617
618# for easier debugging
619modules_to_check := $(sort $(modules_to_check))
620#$(error modules_to_check $(modules_to_check))
621
The Android Open Source Project88b60792009-03-03 19:28:42 -0800622# -------------------------------------------------------------------
623# This is used to to get the ordering right, you can also use these,
624# but they're considered undocumented, so don't complain if their
625# behavior changes.
626.PHONY: prebuilt
627prebuilt: $(ALL_PREBUILT)
628
629# An internal target that depends on all copied headers
630# (see copy_headers.make). Other targets that need the
631# headers to be copied first can depend on this target.
632.PHONY: all_copied_headers
633all_copied_headers: ;
634
635$(ALL_C_CPP_ETC_OBJECTS): | all_copied_headers
636
637# All the droid stuff, in directories
638.PHONY: files
Joe Onoratoe334d252009-07-17 15:33:40 -0400639files: prebuilt \
640 $(modules_to_install) \
641 $(modules_to_check) \
642 $(INSTALLED_ANDROID_INFO_TXT_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800643
644# -------------------------------------------------------------------
645
Joe Onoratoe334d252009-07-17 15:33:40 -0400646.PHONY: checkbuild
647checkbuild: $(modules_to_check)
648
The Android Open Source Project88b60792009-03-03 19:28:42 -0800649.PHONY: ramdisk
650ramdisk: $(INSTALLED_RAMDISK_TARGET)
651
652.PHONY: systemtarball
653systemtarball: $(INSTALLED_SYSTEMTARBALL_TARGET)
654
655.PHONY: userdataimage
656userdataimage: $(INSTALLED_USERDATAIMAGE_TARGET)
657
658.PHONY: userdatatarball
659userdatatarball: $(INSTALLED_USERDATATARBALL_TARGET)
660
661.PHONY: bootimage
662bootimage: $(INSTALLED_BOOTIMAGE_TARGET)
663
664ifeq ($(BUILD_TINY_ANDROID), true)
665INSTALLED_RECOVERYIMAGE_TARGET :=
666endif
667
668# Build files and then package it into the rom formats
669.PHONY: droidcore
670droidcore: files \
671 systemimage \
672 $(INSTALLED_BOOTIMAGE_TARGET) \
673 $(INSTALLED_RECOVERYIMAGE_TARGET) \
674 $(INSTALLED_USERDATAIMAGE_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800675 $(INSTALLED_FILES_FILE)
676
677# The actual files built by the droidcore target changes depending
678# on the build variant.
679.PHONY: droid tests
680droid tests: droidcore
681
682$(call dist-for-goals, droid, \
683 $(INTERNAL_UPDATE_PACKAGE_TARGET) \
684 $(INTERNAL_OTA_PACKAGE_TARGET) \
685 $(SYMBOLS_ZIP) \
686 $(APPS_ZIP) \
687 $(INTERNAL_EMULATOR_PACKAGE_TARGET) \
688 $(PACKAGE_STATS_FILE) \
689 $(INSTALLED_FILES_FILE) \
690 $(INSTALLED_BUILD_PROP_TARGET) \
691 $(BUILT_TARGET_FILES_PACKAGE) \
Ying Wang9a6a1e32010-03-17 17:07:39 -0700692 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800693 )
694
695# Tests are installed in userdata.img. If we're building the tests
696# variant, copy it for "make tests dist". Also copy a zip of the
697# contents of userdata.img, so that people can easily extract a
698# single .apk.
699ifeq ($(TARGET_BUILD_VARIANT),tests)
700$(call dist-for-goals, droid, \
701 $(INSTALLED_USERDATAIMAGE_TARGET) \
702 $(BUILT_TESTS_ZIP_PACKAGE) \
703 )
704endif
705
706.PHONY: docs
707docs: $(ALL_DOCS)
708
709.PHONY: sdk
710ALL_SDK_TARGETS := $(INTERNAL_SDK_TARGET)
711sdk: $(ALL_SDK_TARGETS)
712$(call dist-for-goals,sdk,$(ALL_SDK_TARGETS))
713
714.PHONY: findbugs
715findbugs: $(INTERNAL_FINDBUGS_HTML_TARGET) $(INTERNAL_FINDBUGS_XML_TARGET)
716
717.PHONY: clean
718dirs_to_clean := \
719 $(PRODUCT_OUT) \
720 $(TARGET_COMMON_OUT_ROOT) \
721 $(HOST_OUT) \
722 $(HOST_COMMON_OUT_ROOT)
723clean:
724 @for dir in $(dirs_to_clean) ; do \
725 echo "Cleaning $$dir..."; \
726 rm -rf $$dir; \
727 done
728 @echo "Clean."; \
729
730.PHONY: clobber
731clobber:
732 @rm -rf $(OUT_DIR)
733 @echo "Entire build directory removed."
734
735# The rules for dataclean and installclean are defined in cleanbuild.mk.
736
737#xxx scrape this from ALL_MODULE_NAME_TAGS
738.PHONY: modules
739modules:
740 @echo "Available sub-modules:"
741 @echo "$(call module-names-for-tag-list,$(ALL_MODULE_TAGS))" | \
742 sed -e 's/ */\n/g' | sort -u | $(COLUMN)
743
744.PHONY: showcommands
745showcommands:
746 @echo >/dev/null