blob: a2c2e1ae5ee622fd5b84e264f04891bf9d58d1f1 [file] [log] [blame]
Carl Shapiro7b216702011-06-17 15:09:26 -07001#
2# Copyright (C) 2011 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
Dragos Sbirlea37c19bc2013-07-29 09:38:31 -070017ifndef ANDROID_COMMON_MK
18ANDROID_COMMON_MK = true
19
Brian Carlstrom7940e442013-07-12 13:46:57 -070020# These can be overridden via the environment or by editing to
21# enable/disable certain build configuration.
22#
23# For example, to disable everything but the host debug build you use:
24#
25# (export ART_BUILD_TARGET_NDEBUG=false && export ART_BUILD_TARGET_DEBUG=false && export ART_BUILD_HOST_NDEBUG=false && ...)
26#
27# Beware that tests may use the non-debug build for performance, notable 055-enum-performance
28#
29ART_BUILD_TARGET_NDEBUG ?= true
30ART_BUILD_TARGET_DEBUG ?= true
Brian Carlstrom19e776c2013-07-23 12:16:44 -070031ART_BUILD_HOST_NDEBUG ?= $(WITH_HOST_DALVIK)
32ART_BUILD_HOST_DEBUG ?= $(WITH_HOST_DALVIK)
Brian Carlstrom7940e442013-07-12 13:46:57 -070033
34ifeq ($(ART_BUILD_TARGET_NDEBUG),false)
35$(info Disabling ART_BUILD_TARGET_NDEBUG)
36endif
37ifeq ($(ART_BUILD_TARGET_DEBUG),false)
38$(info Disabling ART_BUILD_TARGET_DEBUG)
39endif
40ifeq ($(ART_BUILD_HOST_NDEBUG),false)
41$(info Disabling ART_BUILD_HOST_NDEBUG)
42endif
43ifeq ($(ART_BUILD_HOST_DEBUG),false)
44$(info Disabling ART_BUILD_HOST_DEBUG)
45endif
46
47#
48# Used to enable smart mode
49#
Anwar Ghuloum8447d842013-04-30 17:27:40 -070050ART_SMALL_MODE := false
51ifneq ($(wildcard art/SMALL_ART),)
52$(info Enabling ART_SMALL_MODE because of existence of art/SMALL_ART)
53ART_SMALL_MODE := true
Ian Rogersf3e98552013-03-20 15:49:49 -070054endif
Anwar Ghulouma72dd8b2013-06-03 17:01:15 -070055ifeq ($(WITH_ART_SMALL_MODE), true)
56ART_SMALL_MODE := true
57endif
Ian Rogersf3e98552013-03-20 15:49:49 -070058
Brian Carlstrom7940e442013-07-12 13:46:57 -070059#
60# Used to enable SEA mode
61#
Dragos Sbirlea7467ee02013-06-21 09:20:34 -070062ART_SEA_IR_MODE := false
63ifneq ($(wildcard art/SEA_IR_ART),)
64$(info Enabling ART_SEA_IR_MODE because of existence of art/SEA_IR_ART)
65ART_SEA_IR_MODE := true
66endif
67ifeq ($(WITH_ART_SEA_IR_MODE), true)
68ART_SEA_IR_MODE := true
69endif
70
Brian Carlstrom7940e442013-07-12 13:46:57 -070071#
72# Used to enable portable mode
73#
Brian Carlstrom06809ed2012-09-17 14:19:20 -070074ART_USE_PORTABLE_COMPILER := false
75ifneq ($(wildcard art/USE_PORTABLE_COMPILER),)
76$(info Enabling ART_USE_PORTABLE_COMPILER because of existence of art/USE_PORTABLE_COMPILER)
77ART_USE_PORTABLE_COMPILER := true
78endif
79ifeq ($(WITH_ART_USE_PORTABLE_COMPILER),true)
80$(info Enabling ART_USE_PORTABLE_COMPILER because WITH_ART_USE_PORTABLE_COMPILER=true)
81ART_USE_PORTABLE_COMPILER := true
82endif
Shih-wei Liaod1fec812012-02-13 09:51:10 -080083
Shih-wei Liaod1fec812012-02-13 09:51:10 -080084LLVM_ROOT_PATH := external/llvm
Ying Wangd9101722013-09-18 09:36:27 -070085# Don't fail a dalvik minimal host build.
86-include $(LLVM_ROOT_PATH)/llvm.mk
Shih-wei Liaod1fec812012-02-13 09:51:10 -080087
Ian Rogerscd5d0422013-05-17 15:54:01 -070088# Clang build.
89# ART_TARGET_CLANG := true
90# ART_HOST_CLANG := true
91
Brian Carlstrom32b4b2a2012-01-31 16:21:40 -080092# directory used for gtests on device
93ART_NATIVETEST_DIR := /data/nativetest/art
94ART_NATIVETEST_OUT := $(TARGET_OUT_DATA_NATIVE_TESTS)/art
95
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070096# directory used for tests on device
97ART_TEST_DIR := /data/art-test
98ART_TEST_OUT := $(TARGET_OUT_DATA)/art-test
99
Brian Carlstromcdc8de42011-07-19 14:23:17 -0700100ART_CPP_EXTENSION := .cc
Carl Shapiro9bf84fd2011-06-17 17:05:25 -0700101
Brian Carlstrom7940e442013-07-12 13:46:57 -0700102ART_HOST_SHLIB_EXTENSION := $(HOST_SHLIB_SUFFIX)
103ART_HOST_SHLIB_EXTENSION ?= .so
104
Elliott Hughes0af55432011-08-17 18:37:28 -0700105ART_C_INCLUDES := \
106 external/gtest/include \
Ian Rogers1d54e732013-05-02 21:10:01 -0700107 external/valgrind/main/include \
Mathieu Chartier75165d02013-09-12 14:00:31 -0700108 external/valgrind/main \
buzbeec143c552011-08-20 17:38:58 -0700109 external/zlib \
Brian Carlstrom7940e442013-07-12 13:46:57 -0700110 frameworks/compile/mclinker/include
Brian Carlstromb0460ea2011-07-29 10:08:05 -0700111
Elliott Hughes1d3f1142011-09-13 12:00:00 -0700112art_cflags := \
Ian Rogers637c65b2013-05-31 11:46:00 -0700113 -fno-rtti \
Mathieu Chartier9b3c3cd2013-08-12 17:41:54 -0700114 -std=gnu++11 \
Carl Shapiro1fb86202011-06-27 17:43:13 -0700115 -ggdb3 \
116 -Wall \
117 -Werror \
118 -Wextra \
Elliott Hugheseaa200d2012-01-05 16:30:31 -0800119 -Wstrict-aliasing=3 \
Carl Shapiro1fb86202011-06-27 17:43:13 -0700120 -fstrict-aliasing
121
Anwar Ghuloumc44f68f2013-05-10 13:24:54 -0700122ifeq ($(ART_SMALL_MODE),true)
123 art_cflags += -DART_SMALL_MODE=1
Ian Rogersf3e98552013-03-20 15:49:49 -0700124endif
125
Dragos Sbirlea7467ee02013-06-21 09:20:34 -0700126ifeq ($(ART_SEA_IR_MODE),true)
127 art_cflags += -DART_SEA_IR_MODE=1
128endif
129
Brian Carlstrom69d7a6b2011-12-15 17:31:21 -0800130ifeq ($(HOST_OS),linux)
Shih-wei Liao24782c62012-01-08 12:46:11 -0800131 art_non_debug_cflags := \
Elliott Hughes3b6baaa2011-10-14 19:13:56 -0700132 -Wframe-larger-than=1728
Brian Carlstrom69d7a6b2011-12-15 17:31:21 -0800133endif
Elliott Hughes3b6baaa2011-10-14 19:13:56 -0700134
Ian Rogers8d11af52013-08-15 14:24:29 -0700135art_non_debug_cflags := \
136 -O3
137
Elliott Hughes3b6baaa2011-10-14 19:13:56 -0700138art_debug_cflags := \
Ian Rogers8d11af52013-08-15 14:24:29 -0700139 -O1 \
Elliott Hughes06e3ad42012-02-07 14:51:57 -0800140 -DDYNAMIC_ANNOTATIONS_ENABLED=1 \
Elliott Hughes3b6baaa2011-10-14 19:13:56 -0700141 -UNDEBUG
142
jeffhao8161c032012-10-31 15:50:00 -0700143# start of image reserved address space
144IMG_HOST_BASE_ADDRESS := 0x60000000
145
146ifeq ($(TARGET_ARCH),mips)
147IMG_TARGET_BASE_ADDRESS := 0x30000000
148else
149IMG_TARGET_BASE_ADDRESS := 0x60000000
150endif
151
Brian Carlstrom1bd2ceb2013-11-06 00:29:48 -0800152ART_HOST_CFLAGS := $(art_cflags) -DANDROID_SMP=1 -DART_BASE_ADDRESS=$(IMG_HOST_BASE_ADDRESS)
153ART_HOST_CFLAGS += -DART_DEFAULT_INSTRUCTION_SET_FEATURES=default
Elliott Hughes1d3f1142011-09-13 12:00:00 -0700154
jeffhao8161c032012-10-31 15:50:00 -0700155ART_TARGET_CFLAGS := $(art_cflags) -DART_TARGET -DART_BASE_ADDRESS=$(IMG_TARGET_BASE_ADDRESS)
Elliott Hughes1d3f1142011-09-13 12:00:00 -0700156ifeq ($(TARGET_CPU_SMP),true)
157 ART_TARGET_CFLAGS += -DANDROID_SMP=1
158else
159 ART_TARGET_CFLAGS += -DANDROID_SMP=0
160endif
161
Brian Carlstrom1bd2ceb2013-11-06 00:29:48 -0800162# DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES is set in ../build/core/dex_preopt.mk based on
163# the TARGET_CPU_VARIANT
164ifeq ($(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES),)
165$(error Required DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES is not set)
166endif
167ART_TARGET_CFLAGS += -DART_DEFAULT_INSTRUCTION_SET_FEATURES=$(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)
168
169ifeq ($(TARGET_ARCH),x86)
170ART_TARGET_CFLAGS += -msse2
171endif
172
Ian Rogersba3ce9a2013-05-17 18:50:09 -0700173# Enable thread-safety for GCC 4.6 on the target but not for GCC 4.7 where this feature was removed.
174ifneq ($(filter 4.6 4.6.%, $(TARGET_GCC_VERSION)),)
175 ART_TARGET_CFLAGS += -Wthread-safety
176else
177 # Warn if not using GCC 4.6 for target builds when not doing a top-level or 'mma' build.
178 ifneq ($(ONE_SHOT_MAKEFILE),)
Dragos Sbirlea37c19bc2013-07-29 09:38:31 -0700179 # Enable target GCC 4.6 with: export TARGET_GCC_VERSION_EXP=4.6
180 $(info Using target GCC $(TARGET_GCC_VERSION) disables thread-safety checks.)
Ian Rogersba3ce9a2013-05-17 18:50:09 -0700181 endif
182endif
183# We build with GCC 4.6 on the host.
184ART_HOST_CFLAGS += -Wthread-safety
185
Ian Rogersf89eccd2013-05-30 10:50:43 -0700186# Make host builds easier to debug and profile by not omitting the frame pointer.
187ART_HOST_CFLAGS += -fno-omit-frame-pointer
188
Brian Carlstrom89521892011-12-07 22:05:07 -0800189# To use oprofile_android --callgraph, uncomment this and recompile with "mmm art -B -j16"
190# ART_TARGET_CFLAGS += -fno-omit-frame-pointer -marm -mapcs
191
Elliott Hughes3b6baaa2011-10-14 19:13:56 -0700192ART_HOST_NON_DEBUG_CFLAGS := $(art_non_debug_cflags)
193ART_TARGET_NON_DEBUG_CFLAGS := $(art_non_debug_cflags)
194
Brian Carlstromfd2ec542012-05-02 15:08:57 -0700195# TODO: move -fkeep-inline-functions to art_debug_cflags when target gcc > 4.4 (and -lsupc++)
Elliott Hughes1ba27142012-01-20 15:32:00 -0800196ART_HOST_DEBUG_CFLAGS := $(art_debug_cflags) -fkeep-inline-functions
Brian Carlstromfd2ec542012-05-02 15:08:57 -0700197ART_HOST_DEBUG_LDLIBS := -lsupc++
Elliott Hughesad6c9c32012-01-19 17:39:12 -0800198
199ifneq ($(HOST_OS),linux)
200 # Some Mac OS pthread header files are broken with -fkeep-inline-functions.
Elliott Hughes34cf5142012-01-20 16:39:13 -0800201 ART_HOST_DEBUG_CFLAGS := $(filter-out -fkeep-inline-functions,$(ART_HOST_DEBUG_CFLAGS))
Elliott Hughes60234562012-06-01 12:25:59 -0700202 # Mac OS doesn't have libsupc++.
203 ART_HOST_DEBUG_LDLIBS := $(filter-out -lsupc++,$(ART_HOST_DEBUG_LDLIBS))
Elliott Hughesad6c9c32012-01-19 17:39:12 -0800204endif
205
Brian Carlstrom86927212011-09-15 11:31:11 -0700206ART_TARGET_DEBUG_CFLAGS := $(art_debug_cflags)
Elliott Hughes1d3f1142011-09-13 12:00:00 -0700207
Ian Rogersc928de92013-02-27 14:30:44 -0800208ifeq ($(ART_USE_PORTABLE_COMPILER),true)
TDYa12758e63f92012-04-24 13:16:47 -0700209PARALLEL_ART_COMPILE_JOBS := -j8
210endif
211
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700212ART_BUILD_TARGET := false
213ART_BUILD_HOST := false
Brian Carlstrom265091e2013-01-30 14:08:26 -0800214ART_BUILD_NDEBUG := false
215ART_BUILD_DEBUG := false
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700216ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
217 ART_BUILD_TARGET := true
Brian Carlstrom265091e2013-01-30 14:08:26 -0800218 ART_BUILD_NDEBUG := true
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700219endif
220ifeq ($(ART_BUILD_TARGET_DEBUG),true)
221 ART_BUILD_TARGET := true
Brian Carlstrom265091e2013-01-30 14:08:26 -0800222 ART_BUILD_DEBUG := true
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700223endif
224ifeq ($(ART_BUILD_HOST_NDEBUG),true)
225 ART_BUILD_HOST := true
Brian Carlstrom265091e2013-01-30 14:08:26 -0800226 ART_BUILD_NDEBUG := true
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700227endif
228ifeq ($(ART_BUILD_HOST_DEBUG),true)
229 ART_BUILD_HOST := true
Brian Carlstrom265091e2013-01-30 14:08:26 -0800230 ART_BUILD_DEBUG := true
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700231endif
Dragos Sbirlea37c19bc2013-07-29 09:38:31 -0700232
233endif # ANDROID_COMMON_MK