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