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