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