Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 1 | # Copyright (C) 2008 The Android Open Source Project |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | # |
| 16 | # Common definitions for host or target builds of libdvm. |
| 17 | # |
Andy McFadden | 12def72 | 2009-12-01 15:53:41 -0800 | [diff] [blame] | 18 | # If you enable or disable optional features here, make sure you do |
| 19 | # a "clean" build -- not everything depends on Dalvik.h. (See Android.mk |
| 20 | # for the exact command.) |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 21 | # |
| 22 | |
| 23 | |
| 24 | # |
| 25 | # Compiler defines. |
| 26 | # |
| 27 | LOCAL_CFLAGS += -fstrict-aliasing -Wstrict-aliasing=2 -fno-align-jumps |
Andy McFadden | d5ab726 | 2009-08-25 07:19:34 -0700 | [diff] [blame] | 28 | #LOCAL_CFLAGS += -DUSE_INDIRECT_REF |
Carl Shapiro | e3c01da | 2010-05-20 22:54:18 -0700 | [diff] [blame] | 29 | LOCAL_CFLAGS += -Wall -Wextra -Wno-unused-parameter |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 30 | |
| 31 | # |
| 32 | # Optional features. These may impact the size or performance of the VM. |
| 33 | # |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 34 | |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 35 | ifeq ($(WITH_DEADLOCK_PREDICTION),true) |
| 36 | LOCAL_CFLAGS += -DWITH_DEADLOCK_PREDICTION |
| 37 | WITH_MONITOR_TRACKING := true |
| 38 | endif |
| 39 | ifeq ($(WITH_MONITOR_TRACKING),true) |
| 40 | LOCAL_CFLAGS += -DWITH_MONITOR_TRACKING |
| 41 | endif |
| 42 | |
| 43 | # Make a debugging version when building the simulator (if not told |
| 44 | # otherwise) and when explicitly asked. |
| 45 | dvm_make_debug_vm := false |
| 46 | ifeq ($(strip $(DEBUG_DALVIK_VM)),) |
| 47 | ifeq ($(dvm_simulator),true) |
| 48 | dvm_make_debug_vm := true |
| 49 | endif |
| 50 | else |
| 51 | dvm_make_debug_vm := $(DEBUG_DALVIK_VM) |
| 52 | endif |
| 53 | |
| 54 | ifeq ($(dvm_make_debug_vm),true) |
| 55 | # |
| 56 | # "Debug" profile: |
| 57 | # - debugger enabled |
| 58 | # - profiling enabled |
| 59 | # - tracked-reference verification enabled |
| 60 | # - allocation limits enabled |
| 61 | # - GDB helpers enabled |
| 62 | # - LOGV |
| 63 | # - assert() |
| 64 | # |
| 65 | LOCAL_CFLAGS += -DWITH_INSTR_CHECKS |
| 66 | LOCAL_CFLAGS += -DWITH_EXTRA_OBJECT_VALIDATION |
| 67 | LOCAL_CFLAGS += -DWITH_TRACKREF_CHECKS |
| 68 | LOCAL_CFLAGS += -DWITH_ALLOC_LIMITS |
| 69 | LOCAL_CFLAGS += -DWITH_EXTRA_GC_CHECKS=1 |
| 70 | #LOCAL_CFLAGS += -DCHECK_MUTEX |
| 71 | #LOCAL_CFLAGS += -DPROFILE_FIELD_ACCESS |
| 72 | LOCAL_CFLAGS += -DDVM_SHOW_EXCEPTION=3 |
| 73 | # add some extra stuff to make it easier to examine with GDB |
| 74 | LOCAL_CFLAGS += -DEASY_GDB |
| 75 | # overall config may be for a "release" build, so reconfigure these |
| 76 | LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1 -DLOG_NDEBUG=1 -DWITH_DALVIK_ASSERT |
| 77 | else # !dvm_make_debug_vm |
| 78 | # |
| 79 | # "Performance" profile: |
| 80 | # - all development features disabled |
| 81 | # - compiler optimizations enabled (redundant for "release" builds) |
| 82 | # - (debugging and profiling still enabled) |
| 83 | # |
| 84 | #LOCAL_CFLAGS += -DNDEBUG -DLOG_NDEBUG=1 |
| 85 | # "-O2" is redundant for device (release) but useful for sim (debug) |
| 86 | #LOCAL_CFLAGS += -O2 -Winline |
| 87 | #LOCAL_CFLAGS += -DWITH_EXTRA_OBJECT_VALIDATION |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 88 | LOCAL_CFLAGS += -DDVM_SHOW_EXCEPTION=1 |
| 89 | # if you want to try with assertions on the device, add: |
| 90 | #LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1 -DLOG_NDEBUG=1 -DWITH_DALVIK_ASSERT |
| 91 | endif # !dvm_make_debug_vm |
| 92 | |
| 93 | # bug hunting: checksum and verify interpreted stack when making JNI calls |
| 94 | #LOCAL_CFLAGS += -DWITH_JNI_STACK_CHECK |
| 95 | |
| 96 | LOCAL_SRC_FILES := \ |
| 97 | AllocTracker.c \ |
Andy McFadden | 38a1786 | 2010-06-16 16:28:07 -0700 | [diff] [blame] | 98 | Atomic.c.arm \ |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 99 | AtomicCache.c \ |
| 100 | CheckJni.c \ |
| 101 | Ddm.c \ |
| 102 | Debugger.c \ |
| 103 | DvmDex.c \ |
| 104 | Exception.c \ |
| 105 | Hash.c \ |
| 106 | IndirectRefTable.c.arm \ |
| 107 | Init.c \ |
| 108 | InlineNative.c.arm \ |
| 109 | Inlines.c \ |
| 110 | Intern.c \ |
| 111 | Jni.c \ |
| 112 | JarFile.c \ |
| 113 | LinearAlloc.c \ |
| 114 | Misc.c.arm \ |
| 115 | Native.c \ |
| 116 | PointerSet.c \ |
| 117 | Profile.c \ |
| 118 | Properties.c \ |
| 119 | RawDexFile.c \ |
| 120 | ReferenceTable.c \ |
| 121 | SignalCatcher.c \ |
| 122 | StdioConverter.c \ |
| 123 | Sync.c \ |
Ben Cheng | c3b92b2 | 2010-01-26 16:46:15 -0800 | [diff] [blame] | 124 | TestCompability.c \ |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 125 | Thread.c \ |
| 126 | UtfString.c \ |
| 127 | alloc/clz.c.arm \ |
| 128 | alloc/Alloc.c \ |
Barry Hayes | 6e5cf60 | 2010-06-22 12:32:59 -0700 | [diff] [blame] | 129 | alloc/CardTable.c \ |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 130 | alloc/HeapBitmap.c.arm \ |
| 131 | alloc/HeapDebug.c \ |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 132 | alloc/HeapTable.c \ |
| 133 | alloc/HeapWorker.c \ |
| 134 | alloc/Heap.c.arm \ |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 135 | alloc/DdmHeap.c \ |
Carl Shapiro | 1e714bb | 2010-03-16 03:26:49 -0700 | [diff] [blame] | 136 | alloc/Verify.c \ |
Carl Shapiro | adc346f | 2010-06-03 23:01:39 -0700 | [diff] [blame] | 137 | alloc/Visit.c \ |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 138 | analysis/CodeVerify.c \ |
Andy McFadden | 2e1ee50 | 2010-03-24 13:25:53 -0700 | [diff] [blame] | 139 | analysis/DexPrepare.c \ |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 140 | analysis/DexVerify.c \ |
Andy McFadden | 2e1ee50 | 2010-03-24 13:25:53 -0700 | [diff] [blame] | 141 | analysis/Optimize.c \ |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 142 | analysis/RegisterMap.c \ |
| 143 | analysis/VerifySubs.c \ |
| 144 | interp/Interp.c.arm \ |
| 145 | interp/Stack.c \ |
| 146 | jdwp/ExpandBuf.c \ |
| 147 | jdwp/JdwpAdb.c \ |
| 148 | jdwp/JdwpConstants.c \ |
| 149 | jdwp/JdwpEvent.c \ |
| 150 | jdwp/JdwpHandler.c \ |
| 151 | jdwp/JdwpMain.c \ |
| 152 | jdwp/JdwpSocket.c \ |
| 153 | mterp/Mterp.c.arm \ |
| 154 | mterp/out/InterpC-portstd.c.arm \ |
| 155 | mterp/out/InterpC-portdbg.c.arm \ |
| 156 | native/InternalNative.c \ |
| 157 | native/dalvik_system_DexFile.c \ |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 158 | native/dalvik_system_VMDebug.c \ |
| 159 | native/dalvik_system_VMRuntime.c \ |
| 160 | native/dalvik_system_VMStack.c \ |
| 161 | native/dalvik_system_Zygote.c \ |
| 162 | native/java_lang_Class.c \ |
| 163 | native/java_lang_Object.c \ |
| 164 | native/java_lang_Runtime.c \ |
| 165 | native/java_lang_String.c \ |
| 166 | native/java_lang_System.c \ |
| 167 | native/java_lang_SystemProperties.c \ |
| 168 | native/java_lang_Throwable.c \ |
| 169 | native/java_lang_VMClassLoader.c \ |
| 170 | native/java_lang_VMThread.c \ |
| 171 | native/java_lang_reflect_AccessibleObject.c \ |
| 172 | native/java_lang_reflect_Array.c \ |
| 173 | native/java_lang_reflect_Constructor.c \ |
| 174 | native/java_lang_reflect_Field.c \ |
| 175 | native/java_lang_reflect_Method.c \ |
| 176 | native/java_lang_reflect_Proxy.c \ |
| 177 | native/java_security_AccessController.c \ |
| 178 | native/java_util_concurrent_atomic_AtomicLong.c \ |
| 179 | native/org_apache_harmony_dalvik_NativeTestTarget.c \ |
| 180 | native/org_apache_harmony_dalvik_ddmc_DdmServer.c \ |
| 181 | native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.c \ |
| 182 | native/sun_misc_Unsafe.c \ |
| 183 | oo/AccessCheck.c \ |
| 184 | oo/Array.c \ |
| 185 | oo/Class.c \ |
| 186 | oo/Object.c \ |
| 187 | oo/Resolve.c \ |
| 188 | oo/TypeCheck.c \ |
| 189 | reflect/Annotation.c \ |
| 190 | reflect/Proxy.c \ |
| 191 | reflect/Reflect.c \ |
Andy McFadden | 38a1786 | 2010-06-16 16:28:07 -0700 | [diff] [blame] | 192 | test/AtomicTest.c.arm \ |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 193 | test/TestHash.c \ |
| 194 | test/TestIndirectRefTable.c |
| 195 | |
Carl Shapiro | d28668c | 2010-04-15 16:10:00 -0700 | [diff] [blame] | 196 | WITH_COPYING_GC := $(strip $(WITH_COPYING_GC)) |
| 197 | |
| 198 | ifeq ($(WITH_COPYING_GC),true) |
| 199 | LOCAL_CFLAGS += -DWITH_COPYING_GC |
| 200 | LOCAL_SRC_FILES += \ |
| 201 | alloc/Copying.c.arm |
| 202 | else |
| 203 | LOCAL_SRC_FILES += \ |
| 204 | alloc/HeapSource.c \ |
| 205 | alloc/MarkSweep.c.arm |
| 206 | endif |
| 207 | |
Ben Cheng | 3f02aa4 | 2009-08-14 13:52:09 -0700 | [diff] [blame] | 208 | WITH_JIT := $(strip $(WITH_JIT)) |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 209 | |
| 210 | ifeq ($(WITH_JIT),true) |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 211 | LOCAL_CFLAGS += -DWITH_JIT |
| 212 | LOCAL_SRC_FILES += \ |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 213 | compiler/Compiler.c \ |
| 214 | compiler/Frontend.c \ |
| 215 | compiler/Utility.c \ |
Ben Cheng | 7a2697d | 2010-06-07 13:44:23 -0700 | [diff] [blame] | 216 | compiler/InlineTransformation.c \ |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 217 | compiler/IntermediateRep.c \ |
Ben Cheng | 4238ec2 | 2009-08-24 16:32:22 -0700 | [diff] [blame] | 218 | compiler/Dataflow.c \ |
| 219 | compiler/Loop.c \ |
Bill Buzbee | 1465db5 | 2009-09-23 17:17:35 -0700 | [diff] [blame] | 220 | compiler/Ralloc.c \ |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 221 | interp/Jit.c |
| 222 | endif |
| 223 | |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 224 | WITH_HPROF := $(strip $(WITH_HPROF)) |
| 225 | ifeq ($(WITH_HPROF),) |
| 226 | WITH_HPROF := true |
| 227 | endif |
| 228 | ifeq ($(WITH_HPROF),true) |
| 229 | LOCAL_SRC_FILES += \ |
| 230 | hprof/Hprof.c \ |
| 231 | hprof/HprofClass.c \ |
| 232 | hprof/HprofHeap.c \ |
| 233 | hprof/HprofOutput.c \ |
| 234 | hprof/HprofString.c |
| 235 | LOCAL_CFLAGS += -DWITH_HPROF=1 |
| 236 | |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 237 | ifeq ($(strip $(WITH_HPROF_STACK)),true) |
| 238 | LOCAL_SRC_FILES += \ |
| 239 | hprof/HprofStack.c \ |
| 240 | hprof/HprofStackFrame.c |
| 241 | LOCAL_CFLAGS += -DWITH_HPROF_STACK=1 |
| 242 | endif # WITH_HPROF_STACK |
| 243 | endif # WITH_HPROF |
| 244 | |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 245 | LOCAL_C_INCLUDES += \ |
| 246 | $(JNI_H_INCLUDE) \ |
| 247 | dalvik \ |
| 248 | dalvik/vm \ |
| 249 | external/zlib \ |
| 250 | $(KERNEL_HEADERS) |
| 251 | |
| 252 | |
| 253 | ifeq ($(dvm_simulator),true) |
| 254 | LOCAL_LDLIBS += -lpthread -ldl |
| 255 | ifeq ($(HOST_OS),linux) |
| 256 | # need this for clock_gettime() in profiling |
| 257 | LOCAL_LDLIBS += -lrt |
| 258 | endif |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 259 | endif |
| 260 | |
| 261 | MTERP_ARCH_KNOWN := false |
| 262 | |
| 263 | ifeq ($(dvm_arch),arm) |
| 264 | #dvm_arch_variant := armv7-a |
| 265 | #LOCAL_CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfp |
Carl Shapiro | cf7fa53 | 2010-06-09 14:23:25 -0700 | [diff] [blame] | 266 | LOCAL_CFLAGS += -Werror |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 267 | MTERP_ARCH_KNOWN := true |
| 268 | # Select architecture-specific sources (armv4t, armv5te etc.) |
| 269 | LOCAL_SRC_FILES += \ |
| 270 | arch/arm/CallOldABI.S \ |
| 271 | arch/arm/CallEABI.S \ |
| 272 | arch/arm/HintsEABI.c \ |
| 273 | mterp/out/InterpC-$(dvm_arch_variant).c.arm \ |
| 274 | mterp/out/InterpAsm-$(dvm_arch_variant).S |
| 275 | |
| 276 | ifeq ($(WITH_JIT),true) |
| 277 | LOCAL_SRC_FILES += \ |
Ben Cheng | 5d90c20 | 2009-11-22 23:31:11 -0800 | [diff] [blame] | 278 | compiler/codegen/arm/RallocUtil.c \ |
| 279 | compiler/codegen/arm/$(dvm_arch_variant)/Codegen.c \ |
Ben Cheng | 24ac537 | 2009-12-16 13:15:53 -0800 | [diff] [blame] | 280 | compiler/codegen/arm/$(dvm_arch_variant)/CallingConvention.S \ |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 281 | compiler/codegen/arm/Assemble.c \ |
| 282 | compiler/codegen/arm/ArchUtility.c \ |
| 283 | compiler/codegen/arm/LocalOptimizations.c \ |
| 284 | compiler/codegen/arm/GlobalOptimizations.c \ |
| 285 | compiler/template/out/CompilerTemplateAsm-$(dvm_arch_variant).S |
| 286 | endif |
| 287 | endif |
| 288 | |
| 289 | ifeq ($(dvm_arch),x86) |
| 290 | ifeq ($(dvm_os),linux) |
| 291 | MTERP_ARCH_KNOWN := true |
| 292 | LOCAL_SRC_FILES += \ |
Johnnie Birch | 22d404a | 2009-04-06 15:26:13 -0700 | [diff] [blame] | 293 | arch/$(dvm_arch_variant)/Call386ABI.S \ |
| 294 | arch/$(dvm_arch_variant)/Hints386ABI.c \ |
| 295 | mterp/out/InterpC-$(dvm_arch_variant).c \ |
| 296 | mterp/out/InterpAsm-$(dvm_arch_variant).S |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 297 | endif |
| 298 | endif |
| 299 | |
| 300 | ifeq ($(dvm_arch),sh) |
| 301 | MTERP_ARCH_KNOWN := true |
| 302 | LOCAL_SRC_FILES += \ |
| 303 | arch/sh/CallSH4ABI.S \ |
| 304 | arch/generic/Hints.c \ |
| 305 | mterp/out/InterpC-allstubs.c \ |
| 306 | mterp/out/InterpAsm-allstubs.S |
| 307 | endif |
| 308 | |
| 309 | ifeq ($(MTERP_ARCH_KNOWN),false) |
| 310 | # unknown architecture, try to use FFI |
| 311 | LOCAL_C_INCLUDES += external/libffi/$(dvm_os)-$(dvm_arch) |
Dan Bornstein | 93194e9 | 2009-08-24 17:50:34 -0700 | [diff] [blame] | 312 | |
| 313 | ifeq ($(dvm_os)-$(dvm_arch),darwin-x86) |
| 314 | # OSX includes libffi, so just make the linker aware of it directly. |
| 315 | LOCAL_LDLIBS += -lffi |
| 316 | else |
| 317 | LOCAL_SHARED_LIBRARIES += libffi |
| 318 | endif |
Dan Bornstein | 4212241 | 2009-07-21 16:08:39 -0700 | [diff] [blame] | 319 | |
| 320 | LOCAL_SRC_FILES += \ |
| 321 | arch/generic/Call.c \ |
| 322 | arch/generic/Hints.c \ |
| 323 | mterp/out/InterpC-allstubs.c |
| 324 | |
| 325 | # The following symbols are usually defined in the asm file, but |
| 326 | # since we don't have an asm file in this case, we instead just |
| 327 | # peg them at 0 here, and we add an #ifdef'able define for good |
| 328 | # measure, too. |
| 329 | LOCAL_CFLAGS += -DdvmAsmInstructionStart=0 -DdvmAsmInstructionEnd=0 \ |
| 330 | -DdvmAsmSisterStart=0 -DdvmAsmSisterEnd=0 -DDVM_NO_ASM_INTERP=1 |
| 331 | endif |
Ben Cheng | c3b92b2 | 2010-01-26 16:46:15 -0800 | [diff] [blame] | 332 | |
| 333 | ifeq ($(TEST_VM_IN_ECLAIR),true) |
| 334 | LOCAL_CFLAGS += -DTEST_VM_IN_ECLAIR |
| 335 | endif |