Home | History | Annotate | Download | only in build
      1 #
      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 
     17 ifndef ANDROID_COMMON_MK
     18 ANDROID_COMMON_MK = true
     19 
     20 # 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 #
     29 ART_BUILD_TARGET_NDEBUG ?= true
     30 ART_BUILD_TARGET_DEBUG ?= true
     31 ART_BUILD_HOST_NDEBUG ?= $(WITH_HOST_DALVIK)
     32 ART_BUILD_HOST_DEBUG ?= $(WITH_HOST_DALVIK)
     33 
     34 ifeq ($(ART_BUILD_TARGET_NDEBUG),false)
     35 $(info Disabling ART_BUILD_TARGET_NDEBUG)
     36 endif
     37 ifeq ($(ART_BUILD_TARGET_DEBUG),false)
     38 $(info Disabling ART_BUILD_TARGET_DEBUG)
     39 endif
     40 ifeq ($(ART_BUILD_HOST_NDEBUG),false)
     41 $(info Disabling ART_BUILD_HOST_NDEBUG)
     42 endif
     43 ifeq ($(ART_BUILD_HOST_DEBUG),false)
     44 $(info Disabling ART_BUILD_HOST_DEBUG)
     45 endif
     46 
     47 #
     48 # Used to enable smart mode
     49 #
     50 ART_SMALL_MODE := false
     51 ifneq ($(wildcard art/SMALL_ART),)
     52 $(info Enabling ART_SMALL_MODE because of existence of art/SMALL_ART)
     53 ART_SMALL_MODE := true
     54 endif
     55 ifeq ($(WITH_ART_SMALL_MODE), true)
     56 ART_SMALL_MODE := true
     57 endif
     58 
     59 #
     60 # Used to enable SEA mode
     61 #
     62 ART_SEA_IR_MODE := false
     63 ifneq ($(wildcard art/SEA_IR_ART),)
     64 $(info Enabling ART_SEA_IR_MODE because of existence of art/SEA_IR_ART)
     65 ART_SEA_IR_MODE := true
     66 endif
     67 ifeq ($(WITH_ART_SEA_IR_MODE), true)
     68 ART_SEA_IR_MODE := true
     69 endif
     70 
     71 #
     72 # Used to enable portable mode
     73 #
     74 ART_USE_PORTABLE_COMPILER := false
     75 ifneq ($(wildcard art/USE_PORTABLE_COMPILER),)
     76 $(info Enabling ART_USE_PORTABLE_COMPILER because of existence of art/USE_PORTABLE_COMPILER)
     77 ART_USE_PORTABLE_COMPILER := true
     78 endif
     79 ifeq ($(WITH_ART_USE_PORTABLE_COMPILER),true)
     80 $(info Enabling ART_USE_PORTABLE_COMPILER because WITH_ART_USE_PORTABLE_COMPILER=true)
     81 ART_USE_PORTABLE_COMPILER := true
     82 endif
     83 
     84 LLVM_ROOT_PATH := external/llvm
     85 include $(LLVM_ROOT_PATH)/llvm.mk
     86 
     87 # Clang build.
     88 # ART_TARGET_CLANG := true
     89 # ART_HOST_CLANG := true
     90 
     91 # directory used for gtests on device
     92 ART_NATIVETEST_DIR := /data/nativetest/art
     93 ART_NATIVETEST_OUT := $(TARGET_OUT_DATA_NATIVE_TESTS)/art
     94 
     95 # directory used for tests on device
     96 ART_TEST_DIR := /data/art-test
     97 ART_TEST_OUT := $(TARGET_OUT_DATA)/art-test
     98 
     99 ART_CPP_EXTENSION := .cc
    100 
    101 ART_HOST_SHLIB_EXTENSION := $(HOST_SHLIB_SUFFIX)
    102 ART_HOST_SHLIB_EXTENSION ?= .so
    103 
    104 ART_C_INCLUDES := \
    105 	external/gtest/include \
    106 	external/valgrind/main/include \
    107 	external/zlib \
    108 	frameworks/compile/mclinker/include
    109 
    110 art_cflags := \
    111 	-fno-rtti \
    112 	-std=gnu++11 \
    113 	-ggdb3 \
    114 	-Wall \
    115 	-Werror \
    116 	-Wextra \
    117 	-Wstrict-aliasing=3 \
    118 	-fstrict-aliasing
    119 
    120 ifeq ($(ART_SMALL_MODE),true)
    121   art_cflags += -DART_SMALL_MODE=1
    122 endif
    123 
    124 ifeq ($(ART_SEA_IR_MODE),true)
    125   art_cflags += -DART_SEA_IR_MODE=1
    126 endif
    127 
    128 ifeq ($(HOST_OS),linux)
    129   art_non_debug_cflags := \
    130 	-Wframe-larger-than=1728
    131 endif
    132 
    133 art_non_debug_cflags := \
    134         -O3
    135 
    136 art_debug_cflags := \
    137 	-O1 \
    138 	-DDYNAMIC_ANNOTATIONS_ENABLED=1 \
    139 	-UNDEBUG
    140 
    141 # start of image reserved address space
    142 IMG_HOST_BASE_ADDRESS   := 0x60000000
    143 
    144 ifeq ($(TARGET_ARCH),mips)
    145 IMG_TARGET_BASE_ADDRESS := 0x30000000
    146 else
    147 IMG_TARGET_BASE_ADDRESS := 0x60000000
    148 endif
    149 
    150 ART_HOST_CFLAGS := $(art_cflags) -DANDROID_SMP=1 -DART_BASE_ADDRESS=$(IMG_HOST_BASE_ADDRESS)
    151 
    152 ifeq ($(TARGET_ARCH),x86)
    153 ART_TARGET_CFLAGS += -msse2
    154 endif
    155 
    156 ART_TARGET_CFLAGS := $(art_cflags) -DART_TARGET -DART_BASE_ADDRESS=$(IMG_TARGET_BASE_ADDRESS)
    157 ifeq ($(TARGET_CPU_SMP),true)
    158   ART_TARGET_CFLAGS += -DANDROID_SMP=1
    159 else
    160   ART_TARGET_CFLAGS += -DANDROID_SMP=0
    161 endif
    162 
    163 # Enable thread-safety for GCC 4.6 on the target but not for GCC 4.7 where this feature was removed.
    164 ifneq ($(filter 4.6 4.6.%, $(TARGET_GCC_VERSION)),)
    165   ART_TARGET_CFLAGS += -Wthread-safety
    166 else
    167   # Warn if not using GCC 4.6 for target builds when not doing a top-level or 'mma' build.
    168   ifneq ($(ONE_SHOT_MAKEFILE),)
    169     # Enable target GCC 4.6 with: export TARGET_GCC_VERSION_EXP=4.6
    170     $(info Using target GCC $(TARGET_GCC_VERSION) disables thread-safety checks.)
    171   endif
    172 endif
    173 # We build with GCC 4.6 on the host.
    174 ART_HOST_CFLAGS += -Wthread-safety
    175 
    176 # Make host builds easier to debug and profile by not omitting the frame pointer.
    177 ART_HOST_CFLAGS += -fno-omit-frame-pointer
    178 
    179 # To use oprofile_android --callgraph, uncomment this and recompile with "mmm art -B -j16"
    180 # ART_TARGET_CFLAGS += -fno-omit-frame-pointer -marm -mapcs
    181 
    182 ART_HOST_NON_DEBUG_CFLAGS := $(art_non_debug_cflags)
    183 ART_TARGET_NON_DEBUG_CFLAGS := $(art_non_debug_cflags)
    184 
    185 # TODO: move -fkeep-inline-functions to art_debug_cflags when target gcc > 4.4 (and -lsupc++)
    186 ART_HOST_DEBUG_CFLAGS := $(art_debug_cflags) -fkeep-inline-functions
    187 ART_HOST_DEBUG_LDLIBS := -lsupc++
    188 
    189 ifneq ($(HOST_OS),linux)
    190   # Some Mac OS pthread header files are broken with -fkeep-inline-functions.
    191   ART_HOST_DEBUG_CFLAGS := $(filter-out -fkeep-inline-functions,$(ART_HOST_DEBUG_CFLAGS))
    192   # Mac OS doesn't have libsupc++.
    193   ART_HOST_DEBUG_LDLIBS := $(filter-out -lsupc++,$(ART_HOST_DEBUG_LDLIBS))
    194 endif
    195 
    196 ART_TARGET_DEBUG_CFLAGS := $(art_debug_cflags)
    197 
    198 ifeq ($(ART_USE_PORTABLE_COMPILER),true)
    199 PARALLEL_ART_COMPILE_JOBS := -j8
    200 endif
    201 
    202 ART_BUILD_TARGET := false
    203 ART_BUILD_HOST := false
    204 ART_BUILD_NDEBUG := false
    205 ART_BUILD_DEBUG := false
    206 ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
    207   ART_BUILD_TARGET := true
    208   ART_BUILD_NDEBUG := true
    209 endif
    210 ifeq ($(ART_BUILD_TARGET_DEBUG),true)
    211   ART_BUILD_TARGET := true
    212   ART_BUILD_DEBUG := true
    213 endif
    214 ifeq ($(ART_BUILD_HOST_NDEBUG),true)
    215   ART_BUILD_HOST := true
    216   ART_BUILD_NDEBUG := true
    217 endif
    218 ifeq ($(ART_BUILD_HOST_DEBUG),true)
    219   ART_BUILD_HOST := true
    220   ART_BUILD_DEBUG := true
    221 endif
    222 
    223 endif # ANDROID_COMMON_MK
    224