config.mk revision bc8abb6fec5063b05fa9ca7f87663caed962bf02
1# 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
6# Use bash, not whatever shell somebody has installed as /bin/sh
7# This is repeated from main.mk, since envsetup.sh runs this file
8# directly.
9SHELL := /bin/bash
10
11# Tell python not to spam the source tree with .pyc files.  This
12# only has an effect on python 2.6 and above.
13export PYTHONDONTWRITEBYTECODE := 1
14
15# Standard source directories.
16SRC_DOCS:= $(TOPDIR)docs
17# TODO: Enforce some kind of layering; only add include paths
18#       when a module links against a particular library.
19# TODO: See if we can remove most of these from the global list.
20SRC_HEADERS := \
21	$(TOPDIR)system/core/include \
22	$(TOPDIR)hardware/libhardware/include \
23	$(TOPDIR)hardware/libhardware_legacy/include \
24	$(TOPDIR)hardware/ril/include \
25	$(TOPDIR)dalvik/libnativehelper/include \
26	$(TOPDIR)frameworks/base/include \
27	$(TOPDIR)frameworks/base/opengl/include \
28	$(TOPDIR)external/skia/include
29SRC_HOST_HEADERS:=$(TOPDIR)tools/include
30SRC_LIBRARIES:= $(TOPDIR)libs
31SRC_SERVERS:= $(TOPDIR)servers
32SRC_TARGET_DIR := $(TOPDIR)build/target
33SRC_API_DIR := $(TOPDIR)frameworks/base/api
34
35# Some specific paths to tools
36SRC_DROIDDOC_DIR := $(TOPDIR)build/tools/droiddoc
37
38# Various mappings to avoid hard-coding paths all over the place
39include $(BUILD_SYSTEM)/pathmap.mk
40
41# ###############################################################
42# Build system internal files
43# ###############################################################
44
45BUILD_COMBOS:= $(BUILD_SYSTEM)/combo
46
47CLEAR_VARS:= $(BUILD_SYSTEM)/clear_vars.mk
48BUILD_HOST_STATIC_LIBRARY:= $(BUILD_SYSTEM)/host_static_library.mk
49BUILD_HOST_SHARED_LIBRARY:= $(BUILD_SYSTEM)/host_shared_library.mk
50BUILD_STATIC_LIBRARY:= $(BUILD_SYSTEM)/static_library.mk
51BUILD_RAW_STATIC_LIBRARY := $(BUILD_SYSTEM)/raw_static_library.mk
52BUILD_SHARED_LIBRARY:= $(BUILD_SYSTEM)/shared_library.mk
53BUILD_EXECUTABLE:= $(BUILD_SYSTEM)/executable.mk
54BUILD_RAW_EXECUTABLE:= $(BUILD_SYSTEM)/raw_executable.mk
55BUILD_HOST_EXECUTABLE:= $(BUILD_SYSTEM)/host_executable.mk
56BUILD_PACKAGE:= $(BUILD_SYSTEM)/package.mk
57BUILD_HOST_PREBUILT:= $(BUILD_SYSTEM)/host_prebuilt.mk
58BUILD_PREBUILT:= $(BUILD_SYSTEM)/prebuilt.mk
59BUILD_MULTI_PREBUILT:= $(BUILD_SYSTEM)/multi_prebuilt.mk
60BUILD_JAVA_LIBRARY:= $(BUILD_SYSTEM)/java_library.mk
61BUILD_STATIC_JAVA_LIBRARY:= $(BUILD_SYSTEM)/static_java_library.mk
62BUILD_HOST_JAVA_LIBRARY:= $(BUILD_SYSTEM)/host_java_library.mk
63BUILD_DROIDDOC:= $(BUILD_SYSTEM)/droiddoc.mk
64BUILD_COPY_HEADERS := $(BUILD_SYSTEM)/copy_headers.mk
65BUILD_KEY_CHAR_MAP := $(BUILD_SYSTEM)/key_char_map.mk
66
67# ###############################################################
68# Parse out any modifier targets.
69# ###############################################################
70
71# The 'showcommands' goal says to show the full command
72# lines being executed, instead of a short message about
73# the kind of operation being done.
74SHOW_COMMANDS:= $(filter showcommands,$(MAKECMDGOALS))
75
76
77# ###############################################################
78# Set common values
79# ###############################################################
80
81# These can be changed to modify both host and device modules.
82COMMON_GLOBAL_CFLAGS:= -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith
83COMMON_RELEASE_CFLAGS:= -DNDEBUG -UDEBUG
84
85COMMON_GLOBAL_CPPFLAGS:= $(COMMON_GLOBAL_CFLAGS) -Wsign-promo
86COMMON_RELEASE_CPPFLAGS:= $(COMMON_RELEASE_CFLAGS)
87
88# Set the extensions used for various packages
89COMMON_PACKAGE_SUFFIX := .zip
90COMMON_JAVA_PACKAGE_SUFFIX := .jar
91COMMON_ANDROID_PACKAGE_SUFFIX := .apk
92
93# list of flags to turn specific warnings in to errors
94TARGET_ERROR_FLAGS := -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point
95
96# TODO: do symbol compression
97TARGET_COMPRESS_MODULE_SYMBOLS := false
98
99# Default is to prelink modules.
100TARGET_PRELINK_MODULE := true
101
102# ###############################################################
103# Include sub-configuration files
104# ###############################################################
105
106# ---------------------------------------------------------------
107# Try to include buildspec.mk, which will try to set stuff up.
108# If this file doesn't exist, the environemnt variables will
109# be used, and if that doesn't work, then the default is an
110# arm build
111-include $(TOPDIR)buildspec.mk
112
113# ---------------------------------------------------------------
114# Define most of the global variables.  These are the ones that
115# are specific to the user's build configuration.
116include $(BUILD_SYSTEM)/envsetup.mk
117
118# Boards may be defined under $(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)
119# or under vendor/*/$(TARGET_DEVICE).  Search in both places, but
120# make sure only one exists.
121# Real boards should always be associated with an OEM vendor.
122board_config_mk := \
123	$(strip $(wildcard \
124		$(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)/BoardConfig.mk \
125		vendor/*/$(TARGET_DEVICE)/BoardConfig.mk \
126	))
127ifeq ($(board_config_mk),)
128  $(error No config file found for TARGET_DEVICE $(TARGET_DEVICE))
129endif
130ifneq ($(words $(board_config_mk)),1)
131  $(error Multiple board config files for TARGET_DEVICE $(TARGET_DEVICE): $(board_config_mk))
132endif
133include $(board_config_mk)
134TARGET_DEVICE_DIR := $(patsubst %/,%,$(dir $(board_config_mk)))
135board_config_mk :=
136
137# Clean up/verify variables defined by the board config file.
138TARGET_BOOTLOADER_BOARD_NAME := $(strip $(TARGET_BOOTLOADER_BOARD_NAME))
139TARGET_CPU_ABI := $(strip $(TARGET_CPU_ABI))
140ifeq ($(TARGET_CPU_ABI),)
141  $(error No TARGET_CPU_ABI defined by board config: $(board_config_mk))
142endif
143TARGET_CPU_ABI2 := $(strip $(TARGET_CPU_ABI2))
144
145# $(1): os/arch
146define select-android-config-h
147system/core/include/arch/$(1)/AndroidConfig.h
148endef
149
150combo_target := HOST_
151include $(BUILD_SYSTEM)/combo/select.mk
152
153# on windows, the tools have .exe at the end, and we depend on the
154# host config stuff being done first
155
156combo_target := TARGET_
157include $(BUILD_SYSTEM)/combo/select.mk
158
159# Pick a Java compiler.
160include $(BUILD_SYSTEM)/combo/javac.mk
161
162# ---------------------------------------------------------------
163# Check that the configuration is current.  We check that
164# BUILD_ENV_SEQUENCE_NUMBER is current against this value.
165# Don't fail if we're called from envsetup, so they have a
166# chance to update their environment.
167
168ifeq (,$(strip $(CALLED_FROM_SETUP)))
169ifneq (,$(strip $(BUILD_ENV_SEQUENCE_NUMBER)))
170ifneq ($(BUILD_ENV_SEQUENCE_NUMBER),$(CORRECT_BUILD_ENV_SEQUENCE_NUMBER))
171$(warning BUILD_ENV_SEQUENCE_NUMBER is set incorrectly.)
172$(info *** If you use envsetup/lunch/choosecombo:)
173$(info ***   - Re-execute envsetup (". envsetup.sh"))
174$(info ***   - Re-run lunch or choosecombo)
175$(info *** If you use buildspec.mk:)
176$(info ***   - Look at buildspec.mk.default to see what has changed)
177$(info ***   - Update BUILD_ENV_SEQUENCE_NUMBER to "$(CORRECT_BUILD_ENV_SEQUENCE_NUMBER)")
178$(error bailing..)
179endif
180endif
181endif
182
183
184# ---------------------------------------------------------------
185# Generic tools.
186
187LEX:= flex
188YACC:= bison -d
189DOXYGEN:= doxygen
190AAPT := $(HOST_OUT_EXECUTABLES)/aapt$(HOST_EXECUTABLE_SUFFIX)
191ACP := $(HOST_OUT_EXECUTABLES)/acp$(HOST_EXECUTABLE_SUFFIX)
192AIDL := $(HOST_OUT_EXECUTABLES)/aidl$(HOST_EXECUTABLE_SUFFIX)
193ICUDATA := $(HOST_OUT_EXECUTABLES)/icudata$(HOST_EXECUTABLE_SUFFIX)
194SIGNAPK_JAR := $(HOST_OUT_JAVA_LIBRARIES)/signapk$(COMMON_JAVA_PACKAGE_SUFFIX)
195MKBOOTFS := $(HOST_OUT_EXECUTABLES)/mkbootfs$(HOST_EXECUTABLE_SUFFIX)
196MINIGZIP := $(HOST_OUT_EXECUTABLES)/minigzip$(HOST_EXECUTABLE_SUFFIX)
197MKBOOTIMG := $(HOST_OUT_EXECUTABLES)/mkbootimg$(HOST_EXECUTABLE_SUFFIX)
198MKYAFFS2 := $(HOST_OUT_EXECUTABLES)/mkyaffs2image$(HOST_EXECUTABLE_SUFFIX)
199APICHECK := $(HOST_OUT_EXECUTABLES)/apicheck$(HOST_EXECUTABLE_SUFFIX)
200FS_GET_STATS := $(HOST_OUT_EXECUTABLES)/fs_get_stats$(HOST_EXECUTABLE_SUFFIX)
201MKEXT2IMG := $(HOST_OUT_EXECUTABLES)/genext2fs$(HOST_EXECUTABLE_SUFFIX)
202MKEXT2BOOTIMG := external/genext2fs/mkbootimg_ext2.sh
203MKTARBALL := build/tools/mktarball.sh
204TUNE2FS := tune2fs
205E2FSCK := e2fsck
206JARJAR := java -jar $(HOST_OUT_JAVA_LIBRARIES)/jarjar.jar
207PROGUARD := external/proguard/bin/proguard.sh
208JAVATAGS := build/tools/java-event-log-tags.py
209
210# dx is java behind a shell script; no .exe necessary.
211DX := $(HOST_OUT_EXECUTABLES)/dx
212KCM := $(HOST_OUT_EXECUTABLES)/kcm$(HOST_EXECUTABLE_SUFFIX)
213ZIPALIGN := $(HOST_OUT_EXECUTABLES)/zipalign$(HOST_EXECUTABLE_SUFFIX)
214FINDBUGS := prebuilt/common/findbugs/bin/findbugs
215LOCALIZE := $(HOST_OUT_EXECUTABLES)/localize$(HOST_EXECUTABLE_SUFFIX)
216EMMA_JAR := external/emma/lib/emma$(COMMON_JAVA_PACKAGE_SUFFIX)
217
218# Binary prelinker/compressor tools
219APRIORI := $(HOST_OUT_EXECUTABLES)/apriori$(HOST_EXECUTABLE_SUFFIX)
220LSD := $(HOST_OUT_EXECUTABLES)/lsd$(HOST_EXECUTABLE_SUFFIX)
221SOSLIM := $(HOST_OUT_EXECUTABLES)/soslim$(HOST_EXECUTABLE_SUFFIX)
222
223# Deal with archaic version of bison on Mac OS X.
224ifeq ($(filter 1.28,$(shell $(YACC) -V)),)
225YACC_HEADER_SUFFIX:= .hpp
226else
227YACC_HEADER_SUFFIX:= .cpp.h
228endif
229
230# Don't use column under Windows, cygwin or not
231ifeq ($(HOST_OS),windows)
232COLUMN:= cat
233else
234COLUMN:= column
235endif
236
237dir := $(shell uname)
238ifeq ($(HOST_OS),windows)
239dir := $(HOST_OS)
240endif
241ifeq ($(HOST_OS),darwin)
242dir := $(HOST_OS)-$(HOST_ARCH)
243endif
244OLD_FLEX := prebuilt/$(HOST_PREBUILT_TAG)/flex/flex-2.5.4a$(HOST_EXECUTABLE_SUFFIX)
245
246ifeq ($(HOST_OS),darwin)
247# Mac OS' screwy version of java uses a non-standard directory layout
248# and doesn't even seem to have tools.jar.  On the other hand, javac seems
249# to be able to magically find the classes in there, wherever they are, so
250# leave this blank
251HOST_JDK_TOOLS_JAR :=
252else
253HOST_JDK_TOOLS_JAR:= $(shell $(BUILD_SYSTEM)/find-jdk-tools-jar.sh)
254endif
255
256# It's called md5 on Mac OS and md5sum on Linux
257ifeq ($(HOST_OS),darwin)
258MD5SUM:=md5 -q
259else
260MD5SUM:=md5sum
261endif
262
263# ###############################################################
264# Set up final options.
265# ###############################################################
266
267HOST_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
268HOST_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
269
270HOST_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
271HOST_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
272
273TARGET_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
274TARGET_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
275
276TARGET_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
277TARGET_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
278
279HOST_GLOBAL_LD_DIRS += -L$(HOST_OUT_INTERMEDIATE_LIBRARIES)
280TARGET_GLOBAL_LD_DIRS += -L$(TARGET_OUT_INTERMEDIATE_LIBRARIES)
281
282HOST_PROJECT_INCLUDES:= $(SRC_HEADERS) $(SRC_HOST_HEADERS) $(HOST_OUT_HEADERS)
283TARGET_PROJECT_INCLUDES:= $(SRC_HEADERS) $(TARGET_OUT_HEADERS)
284
285# Many host compilers don't support these flags, so we have to make
286# sure to only specify them for the target compilers checked in to
287# the source tree. The simulator passes the target flags to the
288# host compiler, so only set them for the target when the target
289# is not the simulator.
290ifneq ($(TARGET_SIMULATOR),true)
291TARGET_GLOBAL_CFLAGS += $(TARGET_ERROR_FLAGS)
292TARGET_GLOBAL_CPPFLAGS += $(TARGET_ERROR_FLAGS)
293endif
294
295HOST_GLOBAL_CFLAGS += $(HOST_RELEASE_CFLAGS)
296HOST_GLOBAL_CPPFLAGS += $(HOST_RELEASE_CPPFLAGS)
297
298TARGET_GLOBAL_CFLAGS += $(TARGET_RELEASE_CFLAGS)
299TARGET_GLOBAL_CPPFLAGS += $(TARGET_RELEASE_CPPFLAGS)
300
301PREBUILT_IS_PRESENT := $(if $(wildcard prebuilt/Android.mk),true)
302
303# ###############################################################
304# Collect a list of the SDK versions that we could compile against
305# For use with the LOCAL_SDK_VERSION variable for include $(BUILD_PACKAGE)
306# ###############################################################
307
308# The files that we can convert into android.jars are are in config/api/*.xml
309# The 'current' version is whatever this source tree is.  Once the apicheck
310# tool can generate the stubs from the xml files, we'll use that to be
311# able to build back-versions.  In the meantime, 'current' is the only
312# one supported.
313#
314# sgrax     is the opposite of xargs.  It takes the list of args and puts them
315#           on each line for sort to process.
316# sort -g   is a numeric sort, so 1 2 3 10 instead of 1 10 2 3.
317TARGET_AVAILABLE_SDK_VERSIONS := current \
318        $(shell function sgrax() { \
319                while [ -n "$$1" ] ; do echo $$1 ; shift ; done \
320            } ; \
321            ( sgrax $(patsubst $(SRC_API_DIR)/%.xml,%, \
322                $(filter-out $(SRC_API_DIR)/current.xml, \
323                $(shell find $(SRC_API_DIR) -name "*.xml"))) | sort -g ) )
324
325
326INTERNAL_PLATFORM_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/public_api.xml
327
328
329
330