blob: f9b711660b535cbf06e7a17d739ec273ec9a3601 [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 \
34 $(TOPDIR)external/skia/include
35SRC_HOST_HEADERS:=$(TOPDIR)tools/include
36SRC_LIBRARIES:= $(TOPDIR)libs
37SRC_SERVERS:= $(TOPDIR)servers
38SRC_TARGET_DIR := $(TOPDIR)build/target
39SRC_API_DIR := $(TOPDIR)frameworks/base/api
40
41# Some specific paths to tools
42SRC_DROIDDOC_DIR := $(TOPDIR)build/tools/droiddoc
43
44# Various mappings to avoid hard-coding paths all over the place
45include $(BUILD_SYSTEM)/pathmap.mk
46
47# ###############################################################
48# Build system internal files
49# ###############################################################
50
51BUILD_COMBOS:= $(BUILD_SYSTEM)/combo
52
53CLEAR_VARS:= $(BUILD_SYSTEM)/clear_vars.mk
54BUILD_HOST_STATIC_LIBRARY:= $(BUILD_SYSTEM)/host_static_library.mk
55BUILD_HOST_SHARED_LIBRARY:= $(BUILD_SYSTEM)/host_shared_library.mk
56BUILD_STATIC_LIBRARY:= $(BUILD_SYSTEM)/static_library.mk
57BUILD_RAW_STATIC_LIBRARY := $(BUILD_SYSTEM)/raw_static_library.mk
58BUILD_SHARED_LIBRARY:= $(BUILD_SYSTEM)/shared_library.mk
59BUILD_EXECUTABLE:= $(BUILD_SYSTEM)/executable.mk
60BUILD_RAW_EXECUTABLE:= $(BUILD_SYSTEM)/raw_executable.mk
61BUILD_HOST_EXECUTABLE:= $(BUILD_SYSTEM)/host_executable.mk
62BUILD_PACKAGE:= $(BUILD_SYSTEM)/package.mk
63BUILD_HOST_PREBUILT:= $(BUILD_SYSTEM)/host_prebuilt.mk
64BUILD_PREBUILT:= $(BUILD_SYSTEM)/prebuilt.mk
65BUILD_MULTI_PREBUILT:= $(BUILD_SYSTEM)/multi_prebuilt.mk
66BUILD_JAVA_LIBRARY:= $(BUILD_SYSTEM)/java_library.mk
67BUILD_STATIC_JAVA_LIBRARY:= $(BUILD_SYSTEM)/static_java_library.mk
68BUILD_HOST_JAVA_LIBRARY:= $(BUILD_SYSTEM)/host_java_library.mk
69BUILD_DROIDDOC:= $(BUILD_SYSTEM)/droiddoc.mk
70BUILD_COPY_HEADERS := $(BUILD_SYSTEM)/copy_headers.mk
71BUILD_KEY_CHAR_MAP := $(BUILD_SYSTEM)/key_char_map.mk
72
73# ###############################################################
74# Parse out any modifier targets.
75# ###############################################################
76
77# The 'showcommands' goal says to show the full command
78# lines being executed, instead of a short message about
79# the kind of operation being done.
80SHOW_COMMANDS:= $(filter showcommands,$(MAKECMDGOALS))
81
82
83# ###############################################################
84# Set common values
85# ###############################################################
86
87# These can be changed to modify both host and device modules.
Marco Nelissene4aaa362009-07-13 20:42:49 -070088COMMON_GLOBAL_CFLAGS:= -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith
The Android Open Source Project88b60792009-03-03 19:28:42 -080089COMMON_RELEASE_CFLAGS:= -DNDEBUG -UDEBUG
90
Marco Nelissen7f0a18f2009-08-13 11:13:21 -070091COMMON_GLOBAL_CPPFLAGS:= $(COMMON_GLOBAL_CFLAGS) -Wsign-promo
Marco Nelissen73a075d2009-07-08 17:51:18 -070092COMMON_RELEASE_CPPFLAGS:= $(COMMON_RELEASE_CFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -080093
94# Set the extensions used for various packages
95COMMON_PACKAGE_SUFFIX := .zip
96COMMON_JAVA_PACKAGE_SUFFIX := .jar
97COMMON_ANDROID_PACKAGE_SUFFIX := .apk
98
99# list of flags to turn specific warnings in to errors
Marco Nelissenbac9a7f2009-07-13 17:51:59 -0700100TARGET_ERROR_FLAGS := -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point
The Android Open Source Project88b60792009-03-03 19:28:42 -0800101
Patrick Scottf4f85a22009-06-25 10:38:26 -0400102# TODO: do symbol compression
103TARGET_COMPRESS_MODULE_SYMBOLS := false
104
105# Default is to prelink modules.
106TARGET_PRELINK_MODULE := true
107
Thorsten Glaser2213aab2010-06-03 19:57:02 +0200108# Default shell is ash. Other possible value is mksh.
109TARGET_SHELL := ash
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
147# Clean up/verify variables defined by the board config file.
148TARGET_BOOTLOADER_BOARD_NAME := $(strip $(TARGET_BOOTLOADER_BOARD_NAME))
149TARGET_CPU_ABI := $(strip $(TARGET_CPU_ABI))
150ifeq ($(TARGET_CPU_ABI),)
151 $(error No TARGET_CPU_ABI defined by board config: $(board_config_mk))
152endif
David 'Digit' Turner2edfb712009-11-06 15:12:00 -0800153TARGET_CPU_ABI2 := $(strip $(TARGET_CPU_ABI2))
Patrick Scott87c86572009-06-23 15:25:06 -0400154
The Android Open Source Project88b60792009-03-03 19:28:42 -0800155# $(1): os/arch
156define select-android-config-h
157system/core/include/arch/$(1)/AndroidConfig.h
158endef
159
160combo_target := HOST_
161include $(BUILD_SYSTEM)/combo/select.mk
162
163# on windows, the tools have .exe at the end, and we depend on the
164# host config stuff being done first
165
166combo_target := TARGET_
167include $(BUILD_SYSTEM)/combo/select.mk
168
169# Pick a Java compiler.
170include $(BUILD_SYSTEM)/combo/javac.mk
171
172# ---------------------------------------------------------------
173# Check that the configuration is current. We check that
174# BUILD_ENV_SEQUENCE_NUMBER is current against this value.
175# Don't fail if we're called from envsetup, so they have a
176# chance to update their environment.
177
178ifeq (,$(strip $(CALLED_FROM_SETUP)))
179ifneq (,$(strip $(BUILD_ENV_SEQUENCE_NUMBER)))
180ifneq ($(BUILD_ENV_SEQUENCE_NUMBER),$(CORRECT_BUILD_ENV_SEQUENCE_NUMBER))
181$(warning BUILD_ENV_SEQUENCE_NUMBER is set incorrectly.)
182$(info *** If you use envsetup/lunch/choosecombo:)
183$(info *** - Re-execute envsetup (". envsetup.sh"))
184$(info *** - Re-run lunch or choosecombo)
185$(info *** If you use buildspec.mk:)
186$(info *** - Look at buildspec.mk.default to see what has changed)
187$(info *** - Update BUILD_ENV_SEQUENCE_NUMBER to "$(CORRECT_BUILD_ENV_SEQUENCE_NUMBER)")
188$(error bailing..)
189endif
190endif
191endif
192
193
194# ---------------------------------------------------------------
195# Generic tools.
196
197LEX:= flex
198YACC:= bison -d
199DOXYGEN:= doxygen
200AAPT := $(HOST_OUT_EXECUTABLES)/aapt$(HOST_EXECUTABLE_SUFFIX)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800201AIDL := $(HOST_OUT_EXECUTABLES)/aidl$(HOST_EXECUTABLE_SUFFIX)
202ICUDATA := $(HOST_OUT_EXECUTABLES)/icudata$(HOST_EXECUTABLE_SUFFIX)
203SIGNAPK_JAR := $(HOST_OUT_JAVA_LIBRARIES)/signapk$(COMMON_JAVA_PACKAGE_SUFFIX)
204MKBOOTFS := $(HOST_OUT_EXECUTABLES)/mkbootfs$(HOST_EXECUTABLE_SUFFIX)
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700205MINIGZIP := $(HOST_OUT_EXECUTABLES)/minigzip$(HOST_EXECUTABLE_SUFFIX)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800206MKBOOTIMG := $(HOST_OUT_EXECUTABLES)/mkbootimg$(HOST_EXECUTABLE_SUFFIX)
207MKYAFFS2 := $(HOST_OUT_EXECUTABLES)/mkyaffs2image$(HOST_EXECUTABLE_SUFFIX)
208APICHECK := $(HOST_OUT_EXECUTABLES)/apicheck$(HOST_EXECUTABLE_SUFFIX)
209FS_GET_STATS := $(HOST_OUT_EXECUTABLES)/fs_get_stats$(HOST_EXECUTABLE_SUFFIX)
210MKEXT2IMG := $(HOST_OUT_EXECUTABLES)/genext2fs$(HOST_EXECUTABLE_SUFFIX)
211MKEXT2BOOTIMG := external/genext2fs/mkbootimg_ext2.sh
212MKTARBALL := build/tools/mktarball.sh
213TUNE2FS := tune2fs
214E2FSCK := e2fsck
215JARJAR := java -jar $(HOST_OUT_JAVA_LIBRARIES)/jarjar.jar
Joe Onorato2daa2b32009-08-30 13:39:24 -0700216PROGUARD := external/proguard/bin/proguard.sh
Doug Zongker9bd49622009-11-30 14:28:59 -0800217JAVATAGS := build/tools/java-event-log-tags.py
The Android Open Source Project88b60792009-03-03 19:28:42 -0800218
Raphael9ca16282010-04-16 17:50:09 -0700219# ACP is always for the build OS, not for the host OS
220ACP := $(BUILD_OUT_EXECUTABLES)/acp$(BUILD_EXECUTABLE_SUFFIX)
221
The Android Open Source Project88b60792009-03-03 19:28:42 -0800222# dx is java behind a shell script; no .exe necessary.
223DX := $(HOST_OUT_EXECUTABLES)/dx
224KCM := $(HOST_OUT_EXECUTABLES)/kcm$(HOST_EXECUTABLE_SUFFIX)
225ZIPALIGN := $(HOST_OUT_EXECUTABLES)/zipalign$(HOST_EXECUTABLE_SUFFIX)
226FINDBUGS := prebuilt/common/findbugs/bin/findbugs
227LOCALIZE := $(HOST_OUT_EXECUTABLES)/localize$(HOST_EXECUTABLE_SUFFIX)
228EMMA_JAR := external/emma/lib/emma$(COMMON_JAVA_PACKAGE_SUFFIX)
229
230# Binary prelinker/compressor tools
231APRIORI := $(HOST_OUT_EXECUTABLES)/apriori$(HOST_EXECUTABLE_SUFFIX)
232LSD := $(HOST_OUT_EXECUTABLES)/lsd$(HOST_EXECUTABLE_SUFFIX)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800233
234# Deal with archaic version of bison on Mac OS X.
235ifeq ($(filter 1.28,$(shell $(YACC) -V)),)
236YACC_HEADER_SUFFIX:= .hpp
237else
238YACC_HEADER_SUFFIX:= .cpp.h
239endif
240
241# Don't use column under Windows, cygwin or not
242ifeq ($(HOST_OS),windows)
243COLUMN:= cat
244else
245COLUMN:= column
246endif
247
248dir := $(shell uname)
249ifeq ($(HOST_OS),windows)
250dir := $(HOST_OS)
251endif
252ifeq ($(HOST_OS),darwin)
253dir := $(HOST_OS)-$(HOST_ARCH)
254endif
255OLD_FLEX := prebuilt/$(HOST_PREBUILT_TAG)/flex/flex-2.5.4a$(HOST_EXECUTABLE_SUFFIX)
256
257ifeq ($(HOST_OS),darwin)
258# Mac OS' screwy version of java uses a non-standard directory layout
259# and doesn't even seem to have tools.jar. On the other hand, javac seems
260# to be able to magically find the classes in there, wherever they are, so
261# leave this blank
262HOST_JDK_TOOLS_JAR :=
263else
264HOST_JDK_TOOLS_JAR:= $(shell $(BUILD_SYSTEM)/find-jdk-tools-jar.sh)
265endif
266
267# It's called md5 on Mac OS and md5sum on Linux
268ifeq ($(HOST_OS),darwin)
269MD5SUM:=md5 -q
270else
271MD5SUM:=md5sum
272endif
273
274# ###############################################################
275# Set up final options.
276# ###############################################################
277
278HOST_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800279HOST_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
280
281HOST_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800282HOST_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
283
284TARGET_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800285TARGET_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
286
287TARGET_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800288TARGET_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
289
290HOST_GLOBAL_LD_DIRS += -L$(HOST_OUT_INTERMEDIATE_LIBRARIES)
291TARGET_GLOBAL_LD_DIRS += -L$(TARGET_OUT_INTERMEDIATE_LIBRARIES)
292
293HOST_PROJECT_INCLUDES:= $(SRC_HEADERS) $(SRC_HOST_HEADERS) $(HOST_OUT_HEADERS)
294TARGET_PROJECT_INCLUDES:= $(SRC_HEADERS) $(TARGET_OUT_HEADERS)
295
296# Many host compilers don't support these flags, so we have to make
297# sure to only specify them for the target compilers checked in to
Dave Bort95282482009-04-23 18:44:55 -0700298# the source tree. The simulator passes the target flags to the
The Android Open Source Project88b60792009-03-03 19:28:42 -0800299# host compiler, so only set them for the target when the target
300# is not the simulator.
301ifneq ($(TARGET_SIMULATOR),true)
302TARGET_GLOBAL_CFLAGS += $(TARGET_ERROR_FLAGS)
303TARGET_GLOBAL_CPPFLAGS += $(TARGET_ERROR_FLAGS)
304endif
305
Dave Bort95282482009-04-23 18:44:55 -0700306HOST_GLOBAL_CFLAGS += $(HOST_RELEASE_CFLAGS)
307HOST_GLOBAL_CPPFLAGS += $(HOST_RELEASE_CPPFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800308
Dave Bort95282482009-04-23 18:44:55 -0700309TARGET_GLOBAL_CFLAGS += $(TARGET_RELEASE_CFLAGS)
310TARGET_GLOBAL_CPPFLAGS += $(TARGET_RELEASE_CPPFLAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800311
The Android Open Source Project88b60792009-03-03 19:28:42 -0800312PREBUILT_IS_PRESENT := $(if $(wildcard prebuilt/Android.mk),true)
313
The Android Open Source Project88b60792009-03-03 19:28:42 -0800314# ###############################################################
315# Collect a list of the SDK versions that we could compile against
316# For use with the LOCAL_SDK_VERSION variable for include $(BUILD_PACKAGE)
317# ###############################################################
318
Ying Wang0f6f4ca2010-06-09 10:26:26 -0700319HISTORICAL_SDK_VERSIONS_ROOT := $(TOPDIR)prebuilt/sdk
320
321# Historical SDK version N is stored in $(HISTORICAL_SDK_VERSIONS_ROOT)/N.
322# The 'current' version is whatever this source tree is.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800323#
324# sgrax is the opposite of xargs. It takes the list of args and puts them
325# on each line for sort to process.
326# 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 -0800327
Ying Wang0f6f4ca2010-06-09 10:26:26 -0700328# Numerically sort a list of numbers
329# $(1): the list of numbers to be sorted
330define numerically_sort
331$(shell function sgrax() { \
332 while [ -n "$$1" ] ; do echo $$1 ; shift ; done \
333 } ; \
334 ( sgrax $(1) | sort -g ) )
335endef
336
337TARGET_AVAILABLE_SDK_VERSIONS := current $(call numerically_sort,\
338 $(patsubst $(HISTORICAL_SDK_VERSIONS_ROOT)/%/android.jar,%, \
339 $(wildcard $(HISTORICAL_SDK_VERSIONS_ROOT)/*/android.jar)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800340
341INTERNAL_PLATFORM_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/public_api.xml
Gary King1e80c292010-03-08 17:16:57 -0800342
Bruce Bearef1582e52010-10-14 14:31:48 -0700343# This is the standard way to name a directory containing prebuilt target
344# objects. E.g., prebuilt/$(TARGET_PREBUILT_TAG)/libc.so
345ifeq ($(TARGET_SIMULATOR),true)
346 TARGET_PREBUILT_TAG := $(TARGET_OS)-$(TARGET_ARCH)
347else
348 TARGET_PREBUILT_TAG := android-$(TARGET_ARCH)
349endif
350
Gary King1e80c292010-03-08 17:16:57 -0800351include $(BUILD_SYSTEM)/dumpvar.mk