config.mk revision f7b32bfe41406daf0785b7451efdbbb9b7bbba7a
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# Only use ANDROID_BUILD_SHELL to wrap around bash.
7# DO NOT use other shells such as zsh.
8ifdef ANDROID_BUILD_SHELL
9SHELL := $(ANDROID_BUILD_SHELL)
10else
11# 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
15endif
16
17# 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
21# 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)frameworks/base/native/include \
35	$(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_PHONY_PACKAGE:= $(BUILD_SYSTEM)/phony_package.mk
65BUILD_HOST_PREBUILT:= $(BUILD_SYSTEM)/host_prebuilt.mk
66BUILD_PREBUILT:= $(BUILD_SYSTEM)/prebuilt.mk
67BUILD_MULTI_PREBUILT:= $(BUILD_SYSTEM)/multi_prebuilt.mk
68BUILD_JAVA_LIBRARY:= $(BUILD_SYSTEM)/java_library.mk
69BUILD_STATIC_JAVA_LIBRARY:= $(BUILD_SYSTEM)/static_java_library.mk
70BUILD_HOST_JAVA_LIBRARY:= $(BUILD_SYSTEM)/host_java_library.mk
71BUILD_DROIDDOC:= $(BUILD_SYSTEM)/droiddoc.mk
72BUILD_COPY_HEADERS := $(BUILD_SYSTEM)/copy_headers.mk
73BUILD_KEY_CHAR_MAP := $(BUILD_SYSTEM)/key_char_map.mk
74BUILD_NATIVE_TEST := $(BUILD_SYSTEM)/native_test.mk
75BUILD_HOST_NATIVE_TEST := $(BUILD_SYSTEM)/host_native_test.mk
76
77# ###############################################################
78# Parse out any modifier targets.
79# ###############################################################
80
81# The 'showcommands' goal says to show the full command
82# lines being executed, instead of a short message about
83# the kind of operation being done.
84SHOW_COMMANDS:= $(filter showcommands,$(MAKECMDGOALS))
85
86
87# ###############################################################
88# Set common values
89# ###############################################################
90
91# These can be changed to modify both host and device modules.
92COMMON_GLOBAL_CFLAGS:= -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith
93COMMON_RELEASE_CFLAGS:= -DNDEBUG -UDEBUG
94
95COMMON_GLOBAL_CPPFLAGS:= $(COMMON_GLOBAL_CFLAGS) -Wsign-promo
96COMMON_RELEASE_CPPFLAGS:= $(COMMON_RELEASE_CFLAGS)
97
98# Set the extensions used for various packages
99COMMON_PACKAGE_SUFFIX := .zip
100COMMON_JAVA_PACKAGE_SUFFIX := .jar
101COMMON_ANDROID_PACKAGE_SUFFIX := .apk
102
103# list of flags to turn specific warnings in to errors
104TARGET_ERROR_FLAGS := -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point
105
106# TODO: do symbol compression
107TARGET_COMPRESS_MODULE_SYMBOLS := false
108
109# Default is to prelink modules.
110TARGET_PRELINK_MODULE := true
111
112# Default shell is ash. Other possible value is mksh.
113TARGET_SHELL := ash
114
115# ###############################################################
116# Include sub-configuration files
117# ###############################################################
118
119# ---------------------------------------------------------------
120# Try to include buildspec.mk, which will try to set stuff up.
121# If this file doesn't exist, the environemnt variables will
122# be used, and if that doesn't work, then the default is an
123# arm build
124-include $(TOPDIR)buildspec.mk
125
126# ---------------------------------------------------------------
127# Define most of the global variables.  These are the ones that
128# are specific to the user's build configuration.
129include $(BUILD_SYSTEM)/envsetup.mk
130
131# Boards may be defined under $(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)
132# or under vendor/*/$(TARGET_DEVICE).  Search in both places, but
133# make sure only one exists.
134# Real boards should always be associated with an OEM vendor.
135board_config_mk := \
136	$(strip $(wildcard \
137		$(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)/BoardConfig.mk \
138		device/*/$(TARGET_DEVICE)/BoardConfig.mk \
139		vendor/*/$(TARGET_DEVICE)/BoardConfig.mk \
140	))
141ifeq ($(board_config_mk),)
142  $(error No config file found for TARGET_DEVICE $(TARGET_DEVICE))
143endif
144ifneq ($(words $(board_config_mk)),1)
145  $(error Multiple board config files for TARGET_DEVICE $(TARGET_DEVICE): $(board_config_mk))
146endif
147include $(board_config_mk)
148TARGET_DEVICE_DIR := $(patsubst %/,%,$(dir $(board_config_mk)))
149board_config_mk :=
150
151# Clean up/verify variables defined by the board config file.
152TARGET_BOOTLOADER_BOARD_NAME := $(strip $(TARGET_BOOTLOADER_BOARD_NAME))
153TARGET_CPU_ABI := $(strip $(TARGET_CPU_ABI))
154ifeq ($(TARGET_CPU_ABI),)
155  $(error No TARGET_CPU_ABI defined by board config: $(board_config_mk))
156endif
157TARGET_CPU_ABI2 := $(strip $(TARGET_CPU_ABI2))
158
159# $(1): os/arch
160define select-android-config-h
161system/core/include/arch/$(1)/AndroidConfig.h
162endef
163
164combo_target := HOST_
165include $(BUILD_SYSTEM)/combo/select.mk
166
167# on windows, the tools have .exe at the end, and we depend on the
168# host config stuff being done first
169
170combo_target := TARGET_
171include $(BUILD_SYSTEM)/combo/select.mk
172
173# Pick a Java compiler.
174include $(BUILD_SYSTEM)/combo/javac.mk
175
176# ---------------------------------------------------------------
177# Check that the configuration is current.  We check that
178# BUILD_ENV_SEQUENCE_NUMBER is current against this value.
179# Don't fail if we're called from envsetup, so they have a
180# chance to update their environment.
181
182ifeq (,$(strip $(CALLED_FROM_SETUP)))
183ifneq (,$(strip $(BUILD_ENV_SEQUENCE_NUMBER)))
184ifneq ($(BUILD_ENV_SEQUENCE_NUMBER),$(CORRECT_BUILD_ENV_SEQUENCE_NUMBER))
185$(warning BUILD_ENV_SEQUENCE_NUMBER is set incorrectly.)
186$(info *** If you use envsetup/lunch/choosecombo:)
187$(info ***   - Re-execute envsetup (". envsetup.sh"))
188$(info ***   - Re-run lunch or choosecombo)
189$(info *** If you use buildspec.mk:)
190$(info ***   - Look at buildspec.mk.default to see what has changed)
191$(info ***   - Update BUILD_ENV_SEQUENCE_NUMBER to "$(CORRECT_BUILD_ENV_SEQUENCE_NUMBER)")
192$(error bailing..)
193endif
194endif
195endif
196
197
198# ---------------------------------------------------------------
199# Generic tools.
200
201LEX:= flex
202YACC:= bison -d
203DOXYGEN:= doxygen
204AAPT := $(HOST_OUT_EXECUTABLES)/aapt$(HOST_EXECUTABLE_SUFFIX)
205AIDL := $(HOST_OUT_EXECUTABLES)/aidl$(HOST_EXECUTABLE_SUFFIX)
206ICUDATA := $(HOST_OUT_EXECUTABLES)/icudata$(HOST_EXECUTABLE_SUFFIX)
207SIGNAPK_JAR := $(HOST_OUT_JAVA_LIBRARIES)/signapk$(COMMON_JAVA_PACKAGE_SUFFIX)
208MKBOOTFS := $(HOST_OUT_EXECUTABLES)/mkbootfs$(HOST_EXECUTABLE_SUFFIX)
209MINIGZIP := $(HOST_OUT_EXECUTABLES)/minigzip$(HOST_EXECUTABLE_SUFFIX)
210MKBOOTIMG := $(HOST_OUT_EXECUTABLES)/mkbootimg$(HOST_EXECUTABLE_SUFFIX)
211MKYAFFS2 := $(HOST_OUT_EXECUTABLES)/mkyaffs2image$(HOST_EXECUTABLE_SUFFIX)
212APICHECK := $(HOST_OUT_EXECUTABLES)/apicheck$(HOST_EXECUTABLE_SUFFIX)
213FS_GET_STATS := $(HOST_OUT_EXECUTABLES)/fs_get_stats$(HOST_EXECUTABLE_SUFFIX)
214MKEXT2IMG := $(HOST_OUT_EXECUTABLES)/genext2fs$(HOST_EXECUTABLE_SUFFIX)
215MAKE_EXT4FS := $(HOST_OUT_EXECUTABLES)/make_ext4fs$(HOST_EXECUTABLE_SUFFIX)
216MKEXT2USERIMG := $(HOST_OUT_EXECUTABLES)/mkuserimg.sh
217MKEXT2BOOTIMG := external/genext2fs/mkbootimg_ext2.sh
218MKTARBALL := build/tools/mktarball.sh
219TUNE2FS := $(HOST_OUT_EXECUTABLES)/tune2fs$(HOST_EXECUTABLE_SUFFIX)
220E2FSCK := $(HOST_OUT_EXECUTABLES)/e2fsck$(HOST_EXECUTABLE_SUFFIX)
221JARJAR := $(HOST_OUT_JAVA_LIBRARIES)/jarjar.jar
222PROGUARD := external/proguard/bin/proguard.sh
223JAVATAGS := build/tools/java-event-log-tags.py
224LLVM_RS_CC := $(HOST_OUT_EXECUTABLES)/llvm-rs-cc$(HOST_EXECUTABLE_SUFFIX)
225LLVM_RS_LINK := $(HOST_OUT_EXECUTABLES)/llvm-rs-link$(HOST_EXECUTABLE_SUFFIX)
226DEXOPT := $(HOST_OUT_EXECUTABLES)/dexopt$(HOST_EXECUTABLE_SUFFIX)
227DEXPREOPT := dalvik/tools/dex-preopt
228
229# ACP is always for the build OS, not for the host OS
230ACP := $(BUILD_OUT_EXECUTABLES)/acp$(BUILD_EXECUTABLE_SUFFIX)
231
232# dx is java behind a shell script; no .exe necessary.
233DX := $(HOST_OUT_EXECUTABLES)/dx
234KCM := $(HOST_OUT_EXECUTABLES)/kcm$(HOST_EXECUTABLE_SUFFIX)
235ZIPALIGN := $(HOST_OUT_EXECUTABLES)/zipalign$(HOST_EXECUTABLE_SUFFIX)
236FINDBUGS := prebuilt/common/findbugs/bin/findbugs
237LOCALIZE := $(HOST_OUT_EXECUTABLES)/localize$(HOST_EXECUTABLE_SUFFIX)
238EMMA_JAR := external/emma/lib/emma$(COMMON_JAVA_PACKAGE_SUFFIX)
239
240# Binary prelinker/compressor tools
241APRIORI := $(HOST_OUT_EXECUTABLES)/apriori$(HOST_EXECUTABLE_SUFFIX)
242LSD := $(HOST_OUT_EXECUTABLES)/lsd$(HOST_EXECUTABLE_SUFFIX)
243
244# Deal with archaic version of bison on Mac OS X.
245ifeq ($(filter 1.28,$(shell $(YACC) -V)),)
246YACC_HEADER_SUFFIX:= .hpp
247else
248YACC_HEADER_SUFFIX:= .cpp.h
249endif
250
251# Don't use column under Windows, cygwin or not
252ifeq ($(HOST_OS),windows)
253COLUMN:= cat
254else
255COLUMN:= column
256endif
257
258dir := $(shell uname)
259ifeq ($(HOST_OS),windows)
260dir := $(HOST_OS)
261endif
262ifeq ($(HOST_OS),darwin)
263dir := $(HOST_OS)-$(HOST_ARCH)
264endif
265OLD_FLEX := prebuilt/$(HOST_PREBUILT_TAG)/flex/flex-2.5.4a$(HOST_EXECUTABLE_SUFFIX)
266
267ifeq ($(HOST_OS),darwin)
268# Mac OS' screwy version of java uses a non-standard directory layout
269# and doesn't even seem to have tools.jar.  On the other hand, javac seems
270# to be able to magically find the classes in there, wherever they are, so
271# leave this blank
272HOST_JDK_TOOLS_JAR :=
273else
274HOST_JDK_TOOLS_JAR:= $(shell $(BUILD_SYSTEM)/find-jdk-tools-jar.sh)
275ifeq ($(wildcard $(HOST_JDK_TOOLS_JAR)),)
276$(error Error: could not find jdk tools.jar, please install JDK6, \
277    which you can download from java.sun.com)
278endif
279endif
280
281# It's called md5 on Mac OS and md5sum on Linux
282ifeq ($(HOST_OS),darwin)
283MD5SUM:=md5 -q
284else
285MD5SUM:=md5sum
286endif
287
288# ###############################################################
289# Set up final options.
290# ###############################################################
291
292HOST_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
293HOST_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
294
295HOST_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
296HOST_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
297
298TARGET_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
299TARGET_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
300
301TARGET_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
302TARGET_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
303
304HOST_GLOBAL_LD_DIRS += -L$(HOST_OUT_INTERMEDIATE_LIBRARIES)
305TARGET_GLOBAL_LD_DIRS += -L$(TARGET_OUT_INTERMEDIATE_LIBRARIES)
306
307HOST_PROJECT_INCLUDES:= $(SRC_HEADERS) $(SRC_HOST_HEADERS) $(HOST_OUT_HEADERS)
308TARGET_PROJECT_INCLUDES:= $(SRC_HEADERS) $(TARGET_OUT_HEADERS)
309
310# Many host compilers don't support these flags, so we have to make
311# sure to only specify them for the target compilers checked in to
312# the source tree. The simulator passes the target flags to the
313# host compiler, so only set them for the target when the target
314# is not the simulator.
315ifneq ($(TARGET_SIMULATOR),true)
316TARGET_GLOBAL_CFLAGS += $(TARGET_ERROR_FLAGS)
317TARGET_GLOBAL_CPPFLAGS += $(TARGET_ERROR_FLAGS)
318endif
319
320HOST_GLOBAL_CFLAGS += $(HOST_RELEASE_CFLAGS)
321HOST_GLOBAL_CPPFLAGS += $(HOST_RELEASE_CPPFLAGS)
322
323TARGET_GLOBAL_CFLAGS += $(TARGET_RELEASE_CFLAGS)
324TARGET_GLOBAL_CPPFLAGS += $(TARGET_RELEASE_CPPFLAGS)
325
326PREBUILT_IS_PRESENT := $(if $(wildcard prebuilt/Android.mk),true)
327
328# ###############################################################
329# Collect a list of the SDK versions that we could compile against
330# For use with the LOCAL_SDK_VERSION variable for include $(BUILD_PACKAGE)
331# ###############################################################
332
333HISTORICAL_SDK_VERSIONS_ROOT := $(TOPDIR)prebuilt/sdk
334HISTORICAL_NDK_VERSIONS_ROOT := $(TOPDIR)prebuilt/ndk
335
336# Historical SDK version N is stored in $(HISTORICAL_SDK_VERSIONS_ROOT)/N.
337# The 'current' version is whatever this source tree is.
338#
339# sgrax     is the opposite of xargs.  It takes the list of args and puts them
340#           on each line for sort to process.
341# sort -g   is a numeric sort, so 1 2 3 10 instead of 1 10 2 3.
342
343# Numerically sort a list of numbers
344# $(1): the list of numbers to be sorted
345define numerically_sort
346$(shell function sgrax() { \
347    while [ -n "$$1" ] ; do echo $$1 ; shift ; done \
348    } ; \
349    ( sgrax $(1) | sort -g ) )
350endef
351
352TARGET_AVAILABLE_SDK_VERSIONS := current $(call numerically_sort,\
353    $(patsubst $(HISTORICAL_SDK_VERSIONS_ROOT)/%/android.jar,%, \
354    $(wildcard $(HISTORICAL_SDK_VERSIONS_ROOT)/*/android.jar)))
355
356TARGET_AVAILABLE_NDK_VERSIONS := $(call numerically_sort,\
357    $(patsubst $(HISTORICAL_NDK_VERSIONS_ROOT)/android-ndk-r%,%, \
358    $(wildcard $(HISTORICAL_NDK_VERSIONS_ROOT)/android-ndk-r*)))
359
360INTERNAL_PLATFORM_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/public_api.xml
361
362include $(BUILD_SYSTEM)/dumpvar.mk
363