blob: a86643546f903f2fa734966600ac97e95d3a78d9 [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001# This is included by the top-level Makefile.
2# It sets up standard variables based on the
3# current configuration and platform, which
4# are not specific to what is being built.
5
Ying Wang6714dbc2010-03-30 16:42:15 -07006# Only use ANDROID_BUILD_SHELL to wrap around bash.
7# DO NOT use other shells such as zsh.
Ying Wang2ce495a2010-03-30 12:55:13 -07008ifdef ANDROID_BUILD_SHELL
9SHELL := $(ANDROID_BUILD_SHELL)
10else
The Android Open Source Project88b60792009-03-03 19:28:42 -080011# Use bash, not whatever shell somebody has installed as /bin/sh
12# This is repeated from main.mk, since envsetup.sh runs this file
13# directly.
14SHELL := /bin/bash
Ying Wang2ce495a2010-03-30 12:55:13 -070015endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080016
Joe Onoratobc8abb62010-01-04 12:57:38 -080017# Tell python not to spam the source tree with .pyc files. This
18# only has an effect on python 2.6 and above.
19export PYTHONDONTWRITEBYTECODE := 1
20
The Android Open Source Project88b60792009-03-03 19:28:42 -080021# Standard source directories.
22SRC_DOCS:= $(TOPDIR)docs
23# TODO: Enforce some kind of layering; only add include paths
24# when a module links against a particular library.
25# TODO: See if we can remove most of these from the global list.
26SRC_HEADERS := \
27 $(TOPDIR)system/core/include \
28 $(TOPDIR)hardware/libhardware/include \
29 $(TOPDIR)hardware/libhardware_legacy/include \
30 $(TOPDIR)hardware/ril/include \
31 $(TOPDIR)dalvik/libnativehelper/include \
32 $(TOPDIR)frameworks/base/include \
33 $(TOPDIR)frameworks/base/opengl/include \
Dianne Hackborn93b01602010-05-04 11:31:59 -070034 $(TOPDIR)frameworks/base/native/include \
The Android Open Source Project88b60792009-03-03 19:28:42 -080035 $(TOPDIR)external/skia/include
36SRC_HOST_HEADERS:=$(TOPDIR)tools/include
37SRC_LIBRARIES:= $(TOPDIR)libs
38SRC_SERVERS:= $(TOPDIR)servers
39SRC_TARGET_DIR := $(TOPDIR)build/target
40SRC_API_DIR := $(TOPDIR)frameworks/base/api
41
42# Some specific paths to tools
43SRC_DROIDDOC_DIR := $(TOPDIR)build/tools/droiddoc
44
45# Various mappings to avoid hard-coding paths all over the place
46include $(BUILD_SYSTEM)/pathmap.mk
47
48# ###############################################################
49# Build system internal files
50# ###############################################################
51
52BUILD_COMBOS:= $(BUILD_SYSTEM)/combo
53
54CLEAR_VARS:= $(BUILD_SYSTEM)/clear_vars.mk
55BUILD_HOST_STATIC_LIBRARY:= $(BUILD_SYSTEM)/host_static_library.mk
56BUILD_HOST_SHARED_LIBRARY:= $(BUILD_SYSTEM)/host_shared_library.mk
57BUILD_STATIC_LIBRARY:= $(BUILD_SYSTEM)/static_library.mk
58BUILD_RAW_STATIC_LIBRARY := $(BUILD_SYSTEM)/raw_static_library.mk
59BUILD_SHARED_LIBRARY:= $(BUILD_SYSTEM)/shared_library.mk
60BUILD_EXECUTABLE:= $(BUILD_SYSTEM)/executable.mk
61BUILD_RAW_EXECUTABLE:= $(BUILD_SYSTEM)/raw_executable.mk
62BUILD_HOST_EXECUTABLE:= $(BUILD_SYSTEM)/host_executable.mk
63BUILD_PACKAGE:= $(BUILD_SYSTEM)/package.mk
64BUILD_HOST_PREBUILT:= $(BUILD_SYSTEM)/host_prebuilt.mk
65BUILD_PREBUILT:= $(BUILD_SYSTEM)/prebuilt.mk
66BUILD_MULTI_PREBUILT:= $(BUILD_SYSTEM)/multi_prebuilt.mk
67BUILD_JAVA_LIBRARY:= $(BUILD_SYSTEM)/java_library.mk
68BUILD_STATIC_JAVA_LIBRARY:= $(BUILD_SYSTEM)/static_java_library.mk
69BUILD_HOST_JAVA_LIBRARY:= $(BUILD_SYSTEM)/host_java_library.mk
70BUILD_DROIDDOC:= $(BUILD_SYSTEM)/droiddoc.mk
71BUILD_COPY_HEADERS := $(BUILD_SYSTEM)/copy_headers.mk
72BUILD_KEY_CHAR_MAP := $(BUILD_SYSTEM)/key_char_map.mk
Ying Wang4c681742010-07-20 11:08:47 -070073BUILD_NATIVE_TEST := $(BUILD_SYSTEM)/native_test.mk
74BUILD_HOST_NATIVE_TEST := $(BUILD_SYSTEM)/host_native_test.mk
The Android Open Source Project88b60792009-03-03 19:28:42 -080075
76# ###############################################################
77# Parse out any modifier targets.
78# ###############################################################
79
80# The 'showcommands' goal says to show the full command
81# lines being executed, instead of a short message about
82# the kind of operation being done.
83SHOW_COMMANDS:= $(filter showcommands,$(MAKECMDGOALS))
84
85
86# ###############################################################
87# Set common values
88# ###############################################################
89
90# These can be changed to modify both host and device modules.
Marco Nelissene4aaa362009-07-13 20:42:49 -070091COMMON_GLOBAL_CFLAGS:= -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith
The Android Open Source Project88b60792009-03-03 19:28:42 -080092COMMON_RELEASE_CFLAGS:= -DNDEBUG -UDEBUG
93
Marco Nelissen7f0a18f2009-08-13 11:13:21 -070094COMMON_GLOBAL_CPPFLAGS:= $(COMMON_GLOBAL_CFLAGS) -Wsign-promo
Marco Nelissen73a075d2009-07-08 17:51:18 -070095COMMON_RELEASE_CPPFLAGS:= $(COMMON_RELEASE_CFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -080096
97# Set the extensions used for various packages
98COMMON_PACKAGE_SUFFIX := .zip
99COMMON_JAVA_PACKAGE_SUFFIX := .jar
100COMMON_ANDROID_PACKAGE_SUFFIX := .apk
101
102# list of flags to turn specific warnings in to errors
Marco Nelissenbac9a7f2009-07-13 17:51:59 -0700103TARGET_ERROR_FLAGS := -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point
The Android Open Source Project88b60792009-03-03 19:28:42 -0800104
Patrick Scottf4f85a22009-06-25 10:38:26 -0400105# TODO: do symbol compression
106TARGET_COMPRESS_MODULE_SYMBOLS := false
107
108# Default is to prelink modules.
109TARGET_PRELINK_MODULE := true
110
The Android Open Source Project88b60792009-03-03 19:28:42 -0800111# ###############################################################
112# Include sub-configuration files
113# ###############################################################
114
115# ---------------------------------------------------------------
116# Try to include buildspec.mk, which will try to set stuff up.
117# If this file doesn't exist, the environemnt variables will
118# be used, and if that doesn't work, then the default is an
119# arm build
120-include $(TOPDIR)buildspec.mk
121
122# ---------------------------------------------------------------
123# Define most of the global variables. These are the ones that
124# are specific to the user's build configuration.
125include $(BUILD_SYSTEM)/envsetup.mk
126
Patrick Scott87c86572009-06-23 15:25:06 -0400127# Boards may be defined under $(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)
128# or under vendor/*/$(TARGET_DEVICE). Search in both places, but
129# make sure only one exists.
130# Real boards should always be associated with an OEM vendor.
131board_config_mk := \
132 $(strip $(wildcard \
133 $(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)/BoardConfig.mk \
Jean-Baptiste Queru8d054162010-01-22 13:25:24 -0800134 device/*/$(TARGET_DEVICE)/BoardConfig.mk \
Patrick Scott87c86572009-06-23 15:25:06 -0400135 vendor/*/$(TARGET_DEVICE)/BoardConfig.mk \
136 ))
137ifeq ($(board_config_mk),)
138 $(error No config file found for TARGET_DEVICE $(TARGET_DEVICE))
139endif
140ifneq ($(words $(board_config_mk)),1)
141 $(error Multiple board config files for TARGET_DEVICE $(TARGET_DEVICE): $(board_config_mk))
142endif
143include $(board_config_mk)
144TARGET_DEVICE_DIR := $(patsubst %/,%,$(dir $(board_config_mk)))
145board_config_mk :=
146
Bruce Beareb73dc662010-07-12 07:53:28 -0700147include $(BUILD_SYSTEM)/dumpvar.mk
148
Patrick Scott87c86572009-06-23 15:25:06 -0400149# Clean up/verify variables defined by the board config file.
150TARGET_BOOTLOADER_BOARD_NAME := $(strip $(TARGET_BOOTLOADER_BOARD_NAME))
151TARGET_CPU_ABI := $(strip $(TARGET_CPU_ABI))
152ifeq ($(TARGET_CPU_ABI),)
153 $(error No TARGET_CPU_ABI defined by board config: $(board_config_mk))
154endif
David 'Digit' Turner2edfb712009-11-06 15:12:00 -0800155TARGET_CPU_ABI2 := $(strip $(TARGET_CPU_ABI2))
Patrick Scott87c86572009-06-23 15:25:06 -0400156
The Android Open Source Project88b60792009-03-03 19:28:42 -0800157# $(1): os/arch
158define select-android-config-h
159system/core/include/arch/$(1)/AndroidConfig.h
160endef
161
162combo_target := HOST_
163include $(BUILD_SYSTEM)/combo/select.mk
164
165# on windows, the tools have .exe at the end, and we depend on the
166# host config stuff being done first
167
168combo_target := TARGET_
169include $(BUILD_SYSTEM)/combo/select.mk
170
171# Pick a Java compiler.
172include $(BUILD_SYSTEM)/combo/javac.mk
173
174# ---------------------------------------------------------------
175# Check that the configuration is current. We check that
176# BUILD_ENV_SEQUENCE_NUMBER is current against this value.
177# Don't fail if we're called from envsetup, so they have a
178# chance to update their environment.
179
180ifeq (,$(strip $(CALLED_FROM_SETUP)))
181ifneq (,$(strip $(BUILD_ENV_SEQUENCE_NUMBER)))
182ifneq ($(BUILD_ENV_SEQUENCE_NUMBER),$(CORRECT_BUILD_ENV_SEQUENCE_NUMBER))
183$(warning BUILD_ENV_SEQUENCE_NUMBER is set incorrectly.)
184$(info *** If you use envsetup/lunch/choosecombo:)
185$(info *** - Re-execute envsetup (". envsetup.sh"))
186$(info *** - Re-run lunch or choosecombo)
187$(info *** If you use buildspec.mk:)
188$(info *** - Look at buildspec.mk.default to see what has changed)
189$(info *** - Update BUILD_ENV_SEQUENCE_NUMBER to "$(CORRECT_BUILD_ENV_SEQUENCE_NUMBER)")
190$(error bailing..)
191endif
192endif
193endif
194
195
196# ---------------------------------------------------------------
197# Generic tools.
198
199LEX:= flex
200YACC:= bison -d
201DOXYGEN:= doxygen
202AAPT := $(HOST_OUT_EXECUTABLES)/aapt$(HOST_EXECUTABLE_SUFFIX)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800203AIDL := $(HOST_OUT_EXECUTABLES)/aidl$(HOST_EXECUTABLE_SUFFIX)
204ICUDATA := $(HOST_OUT_EXECUTABLES)/icudata$(HOST_EXECUTABLE_SUFFIX)
205SIGNAPK_JAR := $(HOST_OUT_JAVA_LIBRARIES)/signapk$(COMMON_JAVA_PACKAGE_SUFFIX)
206MKBOOTFS := $(HOST_OUT_EXECUTABLES)/mkbootfs$(HOST_EXECUTABLE_SUFFIX)
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700207MINIGZIP := $(HOST_OUT_EXECUTABLES)/minigzip$(HOST_EXECUTABLE_SUFFIX)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800208MKBOOTIMG := $(HOST_OUT_EXECUTABLES)/mkbootimg$(HOST_EXECUTABLE_SUFFIX)
209MKYAFFS2 := $(HOST_OUT_EXECUTABLES)/mkyaffs2image$(HOST_EXECUTABLE_SUFFIX)
210APICHECK := $(HOST_OUT_EXECUTABLES)/apicheck$(HOST_EXECUTABLE_SUFFIX)
211FS_GET_STATS := $(HOST_OUT_EXECUTABLES)/fs_get_stats$(HOST_EXECUTABLE_SUFFIX)
212MKEXT2IMG := $(HOST_OUT_EXECUTABLES)/genext2fs$(HOST_EXECUTABLE_SUFFIX)
Colin Cross9dd4ba82010-08-03 14:43:15 -0700213MAKE_EXT4FS := $(HOST_OUT_EXECUTABLES)/make_ext4fs$(HOST_EXECUTABLE_SUFFIX)
Ying Wangc79f4da2010-06-16 14:58:50 -0700214MKEXT2USERIMG := $(HOST_OUT_EXECUTABLES)/mkuserimg.sh
The Android Open Source Project88b60792009-03-03 19:28:42 -0800215MKEXT2BOOTIMG := external/genext2fs/mkbootimg_ext2.sh
216MKTARBALL := build/tools/mktarball.sh
Colin Cross0a7b2c52010-05-07 02:23:59 -0700217TUNE2FS := $(HOST_OUT_EXECUTABLES)/tune2fs$(HOST_EXECUTABLE_SUFFIX)
218E2FSCK := $(HOST_OUT_EXECUTABLES)/e2fsck$(HOST_EXECUTABLE_SUFFIX)
Steve Howardef5c6402010-05-03 15:01:38 -0700219JARJAR := $(HOST_OUT_JAVA_LIBRARIES)/jarjar.jar
Joe Onorato2daa2b32009-08-30 13:39:24 -0700220PROGUARD := external/proguard/bin/proguard.sh
Doug Zongker9bd49622009-11-30 14:28:59 -0800221JAVATAGS := build/tools/java-event-log-tags.py
Ying Wang0bd59a02010-07-15 17:17:52 -0700222SLANG := $(HOST_OUT_EXECUTABLES)/slang$(HOST_EXECUTABLE_SUFFIX)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800223
Raphael9ca16282010-04-16 17:50:09 -0700224# ACP is always for the build OS, not for the host OS
225ACP := $(BUILD_OUT_EXECUTABLES)/acp$(BUILD_EXECUTABLE_SUFFIX)
226
The Android Open Source Project88b60792009-03-03 19:28:42 -0800227# dx is java behind a shell script; no .exe necessary.
228DX := $(HOST_OUT_EXECUTABLES)/dx
229KCM := $(HOST_OUT_EXECUTABLES)/kcm$(HOST_EXECUTABLE_SUFFIX)
230ZIPALIGN := $(HOST_OUT_EXECUTABLES)/zipalign$(HOST_EXECUTABLE_SUFFIX)
231FINDBUGS := prebuilt/common/findbugs/bin/findbugs
232LOCALIZE := $(HOST_OUT_EXECUTABLES)/localize$(HOST_EXECUTABLE_SUFFIX)
233EMMA_JAR := external/emma/lib/emma$(COMMON_JAVA_PACKAGE_SUFFIX)
234
235# Binary prelinker/compressor tools
236APRIORI := $(HOST_OUT_EXECUTABLES)/apriori$(HOST_EXECUTABLE_SUFFIX)
237LSD := $(HOST_OUT_EXECUTABLES)/lsd$(HOST_EXECUTABLE_SUFFIX)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800238
239# Deal with archaic version of bison on Mac OS X.
240ifeq ($(filter 1.28,$(shell $(YACC) -V)),)
241YACC_HEADER_SUFFIX:= .hpp
242else
243YACC_HEADER_SUFFIX:= .cpp.h
244endif
245
246# Don't use column under Windows, cygwin or not
247ifeq ($(HOST_OS),windows)
248COLUMN:= cat
249else
250COLUMN:= column
251endif
252
253dir := $(shell uname)
254ifeq ($(HOST_OS),windows)
255dir := $(HOST_OS)
256endif
257ifeq ($(HOST_OS),darwin)
258dir := $(HOST_OS)-$(HOST_ARCH)
259endif
260OLD_FLEX := prebuilt/$(HOST_PREBUILT_TAG)/flex/flex-2.5.4a$(HOST_EXECUTABLE_SUFFIX)
261
262ifeq ($(HOST_OS),darwin)
263# Mac OS' screwy version of java uses a non-standard directory layout
264# and doesn't even seem to have tools.jar. On the other hand, javac seems
265# to be able to magically find the classes in there, wherever they are, so
266# leave this blank
267HOST_JDK_TOOLS_JAR :=
268else
269HOST_JDK_TOOLS_JAR:= $(shell $(BUILD_SYSTEM)/find-jdk-tools-jar.sh)
Ying Wangec5e7292010-04-26 18:36:52 -0700270ifeq ($(wildcard $(HOST_JDK_TOOLS_JAR)),)
271$(error Error: could not find jdk tools.jar, please install JDK-5.0, \
272 update 12 or higher, which you can download from java.sun.com)
273endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800274endif
275
276# It's called md5 on Mac OS and md5sum on Linux
277ifeq ($(HOST_OS),darwin)
278MD5SUM:=md5 -q
279else
280MD5SUM:=md5sum
281endif
282
283# ###############################################################
284# Set up final options.
285# ###############################################################
286
287HOST_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800288HOST_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
289
290HOST_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800291HOST_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
292
293TARGET_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800294TARGET_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
295
296TARGET_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800297TARGET_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
298
299HOST_GLOBAL_LD_DIRS += -L$(HOST_OUT_INTERMEDIATE_LIBRARIES)
300TARGET_GLOBAL_LD_DIRS += -L$(TARGET_OUT_INTERMEDIATE_LIBRARIES)
301
302HOST_PROJECT_INCLUDES:= $(SRC_HEADERS) $(SRC_HOST_HEADERS) $(HOST_OUT_HEADERS)
303TARGET_PROJECT_INCLUDES:= $(SRC_HEADERS) $(TARGET_OUT_HEADERS)
304
305# Many host compilers don't support these flags, so we have to make
306# sure to only specify them for the target compilers checked in to
Dave Bort95282482009-04-23 18:44:55 -0700307# the source tree. The simulator passes the target flags to the
The Android Open Source Project88b60792009-03-03 19:28:42 -0800308# host compiler, so only set them for the target when the target
309# is not the simulator.
310ifneq ($(TARGET_SIMULATOR),true)
311TARGET_GLOBAL_CFLAGS += $(TARGET_ERROR_FLAGS)
312TARGET_GLOBAL_CPPFLAGS += $(TARGET_ERROR_FLAGS)
313endif
314
Dave Bort95282482009-04-23 18:44:55 -0700315HOST_GLOBAL_CFLAGS += $(HOST_RELEASE_CFLAGS)
316HOST_GLOBAL_CPPFLAGS += $(HOST_RELEASE_CPPFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800317
Dave Bort95282482009-04-23 18:44:55 -0700318TARGET_GLOBAL_CFLAGS += $(TARGET_RELEASE_CFLAGS)
319TARGET_GLOBAL_CPPFLAGS += $(TARGET_RELEASE_CPPFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800320
The Android Open Source Project88b60792009-03-03 19:28:42 -0800321PREBUILT_IS_PRESENT := $(if $(wildcard prebuilt/Android.mk),true)
322
The Android Open Source Project88b60792009-03-03 19:28:42 -0800323# ###############################################################
324# Collect a list of the SDK versions that we could compile against
325# For use with the LOCAL_SDK_VERSION variable for include $(BUILD_PACKAGE)
326# ###############################################################
327
Ying Wang0f6f4ca2010-06-09 10:26:26 -0700328HISTORICAL_SDK_VERSIONS_ROOT := $(TOPDIR)prebuilt/sdk
Ying Wang1a081002010-07-13 14:55:47 -0700329HISTORICAL_NDK_VERSIONS_ROOT := $(TOPDIR)prebuilt/ndk
Ying Wang0f6f4ca2010-06-09 10:26:26 -0700330
331# Historical SDK version N is stored in $(HISTORICAL_SDK_VERSIONS_ROOT)/N.
332# The 'current' version is whatever this source tree is.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800333#
334# sgrax is the opposite of xargs. It takes the list of args and puts them
335# on each line for sort to process.
336# sort -g is a numeric sort, so 1 2 3 10 instead of 1 10 2 3.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800337
Ying Wang0f6f4ca2010-06-09 10:26:26 -0700338# Numerically sort a list of numbers
339# $(1): the list of numbers to be sorted
340define numerically_sort
341$(shell function sgrax() { \
342 while [ -n "$$1" ] ; do echo $$1 ; shift ; done \
343 } ; \
344 ( sgrax $(1) | sort -g ) )
345endef
346
347TARGET_AVAILABLE_SDK_VERSIONS := current $(call numerically_sort,\
348 $(patsubst $(HISTORICAL_SDK_VERSIONS_ROOT)/%/android.jar,%, \
349 $(wildcard $(HISTORICAL_SDK_VERSIONS_ROOT)/*/android.jar)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800350
Ying Wang1a081002010-07-13 14:55:47 -0700351TARGET_AVAILABLE_NDK_VERSIONS := $(call numerically_sort,\
352 $(patsubst $(HISTORICAL_NDK_VERSIONS_ROOT)/android-ndk-r%,%, \
353 $(wildcard $(HISTORICAL_NDK_VERSIONS_ROOT)/android-ndk-r*)))
354
The Android Open Source Project88b60792009-03-03 19:28:42 -0800355INTERNAL_PLATFORM_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/public_api.xml