config.mk revision 8d05416d613af2632eb3dd5763dee468a3b09034
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		device/*/$(TARGET_DEVICE)/BoardConfig.mk \
126		vendor/*/$(TARGET_DEVICE)/BoardConfig.mk \
127	))
128ifeq ($(board_config_mk),)
129  $(error No config file found for TARGET_DEVICE $(TARGET_DEVICE))
130endif
131ifneq ($(words $(board_config_mk)),1)
132  $(error Multiple board config files for TARGET_DEVICE $(TARGET_DEVICE): $(board_config_mk))
133endif
134include $(board_config_mk)
135TARGET_DEVICE_DIR := $(patsubst %/,%,$(dir $(board_config_mk)))
136board_config_mk :=
137
138# Clean up/verify variables defined by the board config file.
139TARGET_BOOTLOADER_BOARD_NAME := $(strip $(TARGET_BOOTLOADER_BOARD_NAME))
140TARGET_CPU_ABI := $(strip $(TARGET_CPU_ABI))
141ifeq ($(TARGET_CPU_ABI),)
142  $(error No TARGET_CPU_ABI defined by board config: $(board_config_mk))
143endif
144TARGET_CPU_ABI2 := $(strip $(TARGET_CPU_ABI2))
145
146# $(1): os/arch
147define select-android-config-h
148system/core/include/arch/$(1)/AndroidConfig.h
149endef
150
151combo_target := HOST_
152include $(BUILD_SYSTEM)/combo/select.mk
153
154# on windows, the tools have .exe at the end, and we depend on the
155# host config stuff being done first
156
157combo_target := TARGET_
158include $(BUILD_SYSTEM)/combo/select.mk
159
160# Pick a Java compiler.
161include $(BUILD_SYSTEM)/combo/javac.mk
162
163# ---------------------------------------------------------------
164# Check that the configuration is current.  We check that
165# BUILD_ENV_SEQUENCE_NUMBER is current against this value.
166# Don't fail if we're called from envsetup, so they have a
167# chance to update their environment.
168
169ifeq (,$(strip $(CALLED_FROM_SETUP)))
170ifneq (,$(strip $(BUILD_ENV_SEQUENCE_NUMBER)))
171ifneq ($(BUILD_ENV_SEQUENCE_NUMBER),$(CORRECT_BUILD_ENV_SEQUENCE_NUMBER))
172$(warning BUILD_ENV_SEQUENCE_NUMBER is set incorrectly.)
173$(info *** If you use envsetup/lunch/choosecombo:)
174$(info ***   - Re-execute envsetup (". envsetup.sh"))
175$(info ***   - Re-run lunch or choosecombo)
176$(info *** If you use buildspec.mk:)
177$(info ***   - Look at buildspec.mk.default to see what has changed)
178$(info ***   - Update BUILD_ENV_SEQUENCE_NUMBER to "$(CORRECT_BUILD_ENV_SEQUENCE_NUMBER)")
179$(error bailing..)
180endif
181endif
182endif
183
184
185# ---------------------------------------------------------------
186# Generic tools.
187
188LEX:= flex
189YACC:= bison -d
190DOXYGEN:= doxygen
191AAPT := $(HOST_OUT_EXECUTABLES)/aapt$(HOST_EXECUTABLE_SUFFIX)
192ACP := $(HOST_OUT_EXECUTABLES)/acp$(HOST_EXECUTABLE_SUFFIX)
193AIDL := $(HOST_OUT_EXECUTABLES)/aidl$(HOST_EXECUTABLE_SUFFIX)
194ICUDATA := $(HOST_OUT_EXECUTABLES)/icudata$(HOST_EXECUTABLE_SUFFIX)
195SIGNAPK_JAR := $(HOST_OUT_JAVA_LIBRARIES)/signapk$(COMMON_JAVA_PACKAGE_SUFFIX)
196MKBOOTFS := $(HOST_OUT_EXECUTABLES)/mkbootfs$(HOST_EXECUTABLE_SUFFIX)
197MINIGZIP := $(HOST_OUT_EXECUTABLES)/minigzip$(HOST_EXECUTABLE_SUFFIX)
198MKBOOTIMG := $(HOST_OUT_EXECUTABLES)/mkbootimg$(HOST_EXECUTABLE_SUFFIX)
199MKYAFFS2 := $(HOST_OUT_EXECUTABLES)/mkyaffs2image$(HOST_EXECUTABLE_SUFFIX)
200APICHECK := $(HOST_OUT_EXECUTABLES)/apicheck$(HOST_EXECUTABLE_SUFFIX)
201FS_GET_STATS := $(HOST_OUT_EXECUTABLES)/fs_get_stats$(HOST_EXECUTABLE_SUFFIX)
202MKEXT2IMG := $(HOST_OUT_EXECUTABLES)/genext2fs$(HOST_EXECUTABLE_SUFFIX)
203MKEXT2BOOTIMG := external/genext2fs/mkbootimg_ext2.sh
204MKTARBALL := build/tools/mktarball.sh
205TUNE2FS := tune2fs
206E2FSCK := e2fsck
207JARJAR := java -jar $(HOST_OUT_JAVA_LIBRARIES)/jarjar.jar
208PROGUARD := external/proguard/bin/proguard.sh
209JAVATAGS := build/tools/java-event-log-tags.py
210
211# dx is java behind a shell script; no .exe necessary.
212DX := $(HOST_OUT_EXECUTABLES)/dx
213KCM := $(HOST_OUT_EXECUTABLES)/kcm$(HOST_EXECUTABLE_SUFFIX)
214ZIPALIGN := $(HOST_OUT_EXECUTABLES)/zipalign$(HOST_EXECUTABLE_SUFFIX)
215FINDBUGS := prebuilt/common/findbugs/bin/findbugs
216LOCALIZE := $(HOST_OUT_EXECUTABLES)/localize$(HOST_EXECUTABLE_SUFFIX)
217EMMA_JAR := external/emma/lib/emma$(COMMON_JAVA_PACKAGE_SUFFIX)
218
219# Binary prelinker/compressor tools
220APRIORI := $(HOST_OUT_EXECUTABLES)/apriori$(HOST_EXECUTABLE_SUFFIX)
221LSD := $(HOST_OUT_EXECUTABLES)/lsd$(HOST_EXECUTABLE_SUFFIX)
222SOSLIM := $(HOST_OUT_EXECUTABLES)/soslim$(HOST_EXECUTABLE_SUFFIX)
223
224# Deal with archaic version of bison on Mac OS X.
225ifeq ($(filter 1.28,$(shell $(YACC) -V)),)
226YACC_HEADER_SUFFIX:= .hpp
227else
228YACC_HEADER_SUFFIX:= .cpp.h
229endif
230
231# Don't use column under Windows, cygwin or not
232ifeq ($(HOST_OS),windows)
233COLUMN:= cat
234else
235COLUMN:= column
236endif
237
238dir := $(shell uname)
239ifeq ($(HOST_OS),windows)
240dir := $(HOST_OS)
241endif
242ifeq ($(HOST_OS),darwin)
243dir := $(HOST_OS)-$(HOST_ARCH)
244endif
245OLD_FLEX := prebuilt/$(HOST_PREBUILT_TAG)/flex/flex-2.5.4a$(HOST_EXECUTABLE_SUFFIX)
246
247ifeq ($(HOST_OS),darwin)
248# Mac OS' screwy version of java uses a non-standard directory layout
249# and doesn't even seem to have tools.jar.  On the other hand, javac seems
250# to be able to magically find the classes in there, wherever they are, so
251# leave this blank
252HOST_JDK_TOOLS_JAR :=
253else
254HOST_JDK_TOOLS_JAR:= $(shell $(BUILD_SYSTEM)/find-jdk-tools-jar.sh)
255endif
256
257# It's called md5 on Mac OS and md5sum on Linux
258ifeq ($(HOST_OS),darwin)
259MD5SUM:=md5 -q
260else
261MD5SUM:=md5sum
262endif
263
264# ###############################################################
265# Set up final options.
266# ###############################################################
267
268HOST_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
269HOST_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
270
271HOST_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
272HOST_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
273
274TARGET_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
275TARGET_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
276
277TARGET_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
278TARGET_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
279
280HOST_GLOBAL_LD_DIRS += -L$(HOST_OUT_INTERMEDIATE_LIBRARIES)
281TARGET_GLOBAL_LD_DIRS += -L$(TARGET_OUT_INTERMEDIATE_LIBRARIES)
282
283HOST_PROJECT_INCLUDES:= $(SRC_HEADERS) $(SRC_HOST_HEADERS) $(HOST_OUT_HEADERS)
284TARGET_PROJECT_INCLUDES:= $(SRC_HEADERS) $(TARGET_OUT_HEADERS)
285
286# Many host compilers don't support these flags, so we have to make
287# sure to only specify them for the target compilers checked in to
288# the source tree. The simulator passes the target flags to the
289# host compiler, so only set them for the target when the target
290# is not the simulator.
291ifneq ($(TARGET_SIMULATOR),true)
292TARGET_GLOBAL_CFLAGS += $(TARGET_ERROR_FLAGS)
293TARGET_GLOBAL_CPPFLAGS += $(TARGET_ERROR_FLAGS)
294endif
295
296HOST_GLOBAL_CFLAGS += $(HOST_RELEASE_CFLAGS)
297HOST_GLOBAL_CPPFLAGS += $(HOST_RELEASE_CPPFLAGS)
298
299TARGET_GLOBAL_CFLAGS += $(TARGET_RELEASE_CFLAGS)
300TARGET_GLOBAL_CPPFLAGS += $(TARGET_RELEASE_CPPFLAGS)
301
302PREBUILT_IS_PRESENT := $(if $(wildcard prebuilt/Android.mk),true)
303
304# ###############################################################
305# Collect a list of the SDK versions that we could compile against
306# For use with the LOCAL_SDK_VERSION variable for include $(BUILD_PACKAGE)
307# ###############################################################
308
309# The files that we can convert into android.jars are are in config/api/*.xml
310# The 'current' version is whatever this source tree is.  Once the apicheck
311# tool can generate the stubs from the xml files, we'll use that to be
312# able to build back-versions.  In the meantime, 'current' is the only
313# one supported.
314#
315# sgrax     is the opposite of xargs.  It takes the list of args and puts them
316#           on each line for sort to process.
317# sort -g   is a numeric sort, so 1 2 3 10 instead of 1 10 2 3.
318TARGET_AVAILABLE_SDK_VERSIONS := current \
319        $(shell function sgrax() { \
320                while [ -n "$$1" ] ; do echo $$1 ; shift ; done \
321            } ; \
322            ( sgrax $(patsubst $(SRC_API_DIR)/%.xml,%, \
323                $(filter-out $(SRC_API_DIR)/current.xml, \
324                $(shell find $(SRC_API_DIR) -name "*.xml"))) | sort -g ) )
325
326
327INTERNAL_PLATFORM_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/public_api.xml
328
329
330
331