blob: 85fc59806e8612ada17c36464c5de10efc5b68a4 [file] [log] [blame]
Dan Bornstein42122412009-07-21 16:08:39 -07001# 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 McFadden12def722009-12-01 15:53:41 -080018# 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 Bornstein42122412009-07-21 16:08:39 -070021#
22
23
24#
25# Compiler defines.
26#
27LOCAL_CFLAGS += -fstrict-aliasing -Wstrict-aliasing=2 -fno-align-jumps
Andy McFaddend5ab7262009-08-25 07:19:34 -070028#LOCAL_CFLAGS += -DUSE_INDIRECT_REF
Carl Shapiroe3c01da2010-05-20 22:54:18 -070029LOCAL_CFLAGS += -Wall -Wextra -Wno-unused-parameter
Dan Bornstein42122412009-07-21 16:08:39 -070030
31#
32# Optional features. These may impact the size or performance of the VM.
33#
Dan Bornstein42122412009-07-21 16:08:39 -070034
Dan Bornstein42122412009-07-21 16:08:39 -070035ifeq ($(WITH_DEADLOCK_PREDICTION),true)
36 LOCAL_CFLAGS += -DWITH_DEADLOCK_PREDICTION
37 WITH_MONITOR_TRACKING := true
38endif
39ifeq ($(WITH_MONITOR_TRACKING),true)
40 LOCAL_CFLAGS += -DWITH_MONITOR_TRACKING
41endif
42
43# Make a debugging version when building the simulator (if not told
44# otherwise) and when explicitly asked.
45dvm_make_debug_vm := false
46ifeq ($(strip $(DEBUG_DALVIK_VM)),)
47 ifeq ($(dvm_simulator),true)
48 dvm_make_debug_vm := true
49 endif
50else
51 dvm_make_debug_vm := $(DEBUG_DALVIK_VM)
52endif
53
54ifeq ($(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
77else # !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 Bornstein42122412009-07-21 16:08:39 -070088 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
91endif # !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
96LOCAL_SRC_FILES := \
97 AllocTracker.c \
Andy McFadden38a17862010-06-16 16:28:07 -070098 Atomic.c.arm \
Dan Bornstein42122412009-07-21 16:08:39 -070099 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 Chengc3b92b22010-01-26 16:46:15 -0800124 TestCompability.c \
Dan Bornstein42122412009-07-21 16:08:39 -0700125 Thread.c \
126 UtfString.c \
127 alloc/clz.c.arm \
128 alloc/Alloc.c \
Barry Hayes6e5cf602010-06-22 12:32:59 -0700129 alloc/CardTable.c \
Dan Bornstein42122412009-07-21 16:08:39 -0700130 alloc/HeapBitmap.c.arm \
131 alloc/HeapDebug.c \
Dan Bornstein42122412009-07-21 16:08:39 -0700132 alloc/HeapTable.c \
133 alloc/HeapWorker.c \
134 alloc/Heap.c.arm \
Dan Bornstein42122412009-07-21 16:08:39 -0700135 alloc/DdmHeap.c \
Carl Shapiro1e714bb2010-03-16 03:26:49 -0700136 alloc/Verify.c \
Carl Shapiroadc346f2010-06-03 23:01:39 -0700137 alloc/Visit.c \
Dan Bornstein42122412009-07-21 16:08:39 -0700138 analysis/CodeVerify.c \
Andy McFadden2e1ee502010-03-24 13:25:53 -0700139 analysis/DexPrepare.c \
Dan Bornstein42122412009-07-21 16:08:39 -0700140 analysis/DexVerify.c \
Andy McFadden2e1ee502010-03-24 13:25:53 -0700141 analysis/Optimize.c \
Dan Bornstein42122412009-07-21 16:08:39 -0700142 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 Bornstein42122412009-07-21 16:08:39 -0700158 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 McFadden38a17862010-06-16 16:28:07 -0700192 test/AtomicTest.c.arm \
Dan Bornstein42122412009-07-21 16:08:39 -0700193 test/TestHash.c \
194 test/TestIndirectRefTable.c
195
Carl Shapirod28668c2010-04-15 16:10:00 -0700196WITH_COPYING_GC := $(strip $(WITH_COPYING_GC))
197
198ifeq ($(WITH_COPYING_GC),true)
199 LOCAL_CFLAGS += -DWITH_COPYING_GC
200 LOCAL_SRC_FILES += \
201 alloc/Copying.c.arm
202else
203 LOCAL_SRC_FILES += \
204 alloc/HeapSource.c \
205 alloc/MarkSweep.c.arm
206endif
207
Ben Cheng3f02aa42009-08-14 13:52:09 -0700208WITH_JIT := $(strip $(WITH_JIT))
Dan Bornstein42122412009-07-21 16:08:39 -0700209
210ifeq ($(WITH_JIT),true)
Dan Bornstein42122412009-07-21 16:08:39 -0700211 LOCAL_CFLAGS += -DWITH_JIT
212 LOCAL_SRC_FILES += \
Dan Bornstein42122412009-07-21 16:08:39 -0700213 compiler/Compiler.c \
214 compiler/Frontend.c \
215 compiler/Utility.c \
Ben Cheng7a2697d2010-06-07 13:44:23 -0700216 compiler/InlineTransformation.c \
Dan Bornstein42122412009-07-21 16:08:39 -0700217 compiler/IntermediateRep.c \
Ben Cheng4238ec22009-08-24 16:32:22 -0700218 compiler/Dataflow.c \
219 compiler/Loop.c \
Bill Buzbee1465db52009-09-23 17:17:35 -0700220 compiler/Ralloc.c \
Dan Bornstein42122412009-07-21 16:08:39 -0700221 interp/Jit.c
222endif
223
Dan Bornstein42122412009-07-21 16:08:39 -0700224WITH_HPROF := $(strip $(WITH_HPROF))
225ifeq ($(WITH_HPROF),)
226 WITH_HPROF := true
227endif
228ifeq ($(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 Bornstein42122412009-07-21 16:08:39 -0700237 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
243endif # WITH_HPROF
244
Dan Bornstein42122412009-07-21 16:08:39 -0700245LOCAL_C_INCLUDES += \
246 $(JNI_H_INCLUDE) \
247 dalvik \
248 dalvik/vm \
249 external/zlib \
250 $(KERNEL_HEADERS)
251
252
253ifeq ($(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 Bornstein42122412009-07-21 16:08:39 -0700259endif
260
261MTERP_ARCH_KNOWN := false
262
263ifeq ($(dvm_arch),arm)
264 #dvm_arch_variant := armv7-a
265 #LOCAL_CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfp
Carl Shapirocf7fa532010-06-09 14:23:25 -0700266 LOCAL_CFLAGS += -Werror
Dan Bornstein42122412009-07-21 16:08:39 -0700267 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 Cheng5d90c202009-11-22 23:31:11 -0800278 compiler/codegen/arm/RallocUtil.c \
279 compiler/codegen/arm/$(dvm_arch_variant)/Codegen.c \
Ben Cheng24ac5372009-12-16 13:15:53 -0800280 compiler/codegen/arm/$(dvm_arch_variant)/CallingConvention.S \
Dan Bornstein42122412009-07-21 16:08:39 -0700281 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
287endif
288
289ifeq ($(dvm_arch),x86)
290 ifeq ($(dvm_os),linux)
291 MTERP_ARCH_KNOWN := true
292 LOCAL_SRC_FILES += \
Johnnie Birch22d404a2009-04-06 15:26:13 -0700293 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 Bornstein42122412009-07-21 16:08:39 -0700297 endif
298endif
299
300ifeq ($(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
307endif
308
309ifeq ($(MTERP_ARCH_KNOWN),false)
310 # unknown architecture, try to use FFI
311 LOCAL_C_INCLUDES += external/libffi/$(dvm_os)-$(dvm_arch)
Dan Bornstein93194e92009-08-24 17:50:34 -0700312
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 Bornstein42122412009-07-21 16:08:39 -0700319
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
331endif
Ben Chengc3b92b22010-01-26 16:46:15 -0800332
333ifeq ($(TEST_VM_IN_ECLAIR),true)
334 LOCAL_CFLAGS += -DTEST_VM_IN_ECLAIR
335endif