blob: cf0d0c9dd8ab060721ddb5a57887af25c9358d64 [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
Dan Bornstein42122412009-07-21 16:08:39 -070029
30#
31# Optional features. These may impact the size or performance of the VM.
32#
33LOCAL_CFLAGS += -DWITH_PROFILER -DWITH_DEBUGGER
34
35# 0=full cache, 1/2=reduced, 3=no cache
36LOCAL_CFLAGS += -DDVM_RESOLVER_CACHE=0
37
38ifeq ($(WITH_DEADLOCK_PREDICTION),true)
39 LOCAL_CFLAGS += -DWITH_DEADLOCK_PREDICTION
40 WITH_MONITOR_TRACKING := true
41endif
42ifeq ($(WITH_MONITOR_TRACKING),true)
43 LOCAL_CFLAGS += -DWITH_MONITOR_TRACKING
44endif
45
46# Make a debugging version when building the simulator (if not told
47# otherwise) and when explicitly asked.
48dvm_make_debug_vm := false
49ifeq ($(strip $(DEBUG_DALVIK_VM)),)
50 ifeq ($(dvm_simulator),true)
51 dvm_make_debug_vm := true
52 endif
53else
54 dvm_make_debug_vm := $(DEBUG_DALVIK_VM)
55endif
56
57ifeq ($(dvm_make_debug_vm),true)
58 #
59 # "Debug" profile:
60 # - debugger enabled
61 # - profiling enabled
62 # - tracked-reference verification enabled
63 # - allocation limits enabled
64 # - GDB helpers enabled
65 # - LOGV
66 # - assert()
67 #
68 LOCAL_CFLAGS += -DWITH_INSTR_CHECKS
69 LOCAL_CFLAGS += -DWITH_EXTRA_OBJECT_VALIDATION
70 LOCAL_CFLAGS += -DWITH_TRACKREF_CHECKS
71 LOCAL_CFLAGS += -DWITH_ALLOC_LIMITS
72 LOCAL_CFLAGS += -DWITH_EXTRA_GC_CHECKS=1
73 #LOCAL_CFLAGS += -DCHECK_MUTEX
74 #LOCAL_CFLAGS += -DPROFILE_FIELD_ACCESS
75 LOCAL_CFLAGS += -DDVM_SHOW_EXCEPTION=3
76 # add some extra stuff to make it easier to examine with GDB
77 LOCAL_CFLAGS += -DEASY_GDB
78 # overall config may be for a "release" build, so reconfigure these
79 LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1 -DLOG_NDEBUG=1 -DWITH_DALVIK_ASSERT
80else # !dvm_make_debug_vm
81 #
82 # "Performance" profile:
83 # - all development features disabled
84 # - compiler optimizations enabled (redundant for "release" builds)
85 # - (debugging and profiling still enabled)
86 #
87 #LOCAL_CFLAGS += -DNDEBUG -DLOG_NDEBUG=1
88 # "-O2" is redundant for device (release) but useful for sim (debug)
89 #LOCAL_CFLAGS += -O2 -Winline
90 #LOCAL_CFLAGS += -DWITH_EXTRA_OBJECT_VALIDATION
Dan Bornstein42122412009-07-21 16:08:39 -070091 LOCAL_CFLAGS += -DDVM_SHOW_EXCEPTION=1
92 # if you want to try with assertions on the device, add:
93 #LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1 -DLOG_NDEBUG=1 -DWITH_DALVIK_ASSERT
94endif # !dvm_make_debug_vm
95
96# bug hunting: checksum and verify interpreted stack when making JNI calls
97#LOCAL_CFLAGS += -DWITH_JNI_STACK_CHECK
98
99LOCAL_SRC_FILES := \
100 AllocTracker.c \
101 AtomicCache.c \
102 CheckJni.c \
103 Ddm.c \
104 Debugger.c \
105 DvmDex.c \
106 Exception.c \
107 Hash.c \
108 IndirectRefTable.c.arm \
109 Init.c \
110 InlineNative.c.arm \
111 Inlines.c \
112 Intern.c \
113 Jni.c \
114 JarFile.c \
115 LinearAlloc.c \
116 Misc.c.arm \
117 Native.c \
118 PointerSet.c \
119 Profile.c \
120 Properties.c \
121 RawDexFile.c \
122 ReferenceTable.c \
123 SignalCatcher.c \
124 StdioConverter.c \
125 Sync.c \
Ben Chengc3b92b22010-01-26 16:46:15 -0800126 TestCompability.c \
Dan Bornstein42122412009-07-21 16:08:39 -0700127 Thread.c \
128 UtfString.c \
129 alloc/clz.c.arm \
130 alloc/Alloc.c \
131 alloc/HeapBitmap.c.arm \
132 alloc/HeapDebug.c \
133 alloc/HeapSource.c \
134 alloc/HeapTable.c \
135 alloc/HeapWorker.c \
136 alloc/Heap.c.arm \
137 alloc/MarkSweep.c.arm \
138 alloc/DdmHeap.c \
Carl Shapiro1e714bb2010-03-16 03:26:49 -0700139 alloc/Verify.c \
Dan Bornstein42122412009-07-21 16:08:39 -0700140 analysis/CodeVerify.c \
141 analysis/DexOptimize.c \
142 analysis/DexVerify.c \
143 analysis/ReduceConstants.c \
144 analysis/RegisterMap.c \
145 analysis/VerifySubs.c \
146 interp/Interp.c.arm \
147 interp/Stack.c \
148 jdwp/ExpandBuf.c \
149 jdwp/JdwpAdb.c \
150 jdwp/JdwpConstants.c \
151 jdwp/JdwpEvent.c \
152 jdwp/JdwpHandler.c \
153 jdwp/JdwpMain.c \
154 jdwp/JdwpSocket.c \
155 mterp/Mterp.c.arm \
156 mterp/out/InterpC-portstd.c.arm \
157 mterp/out/InterpC-portdbg.c.arm \
158 native/InternalNative.c \
159 native/dalvik_system_DexFile.c \
160 native/dalvik_system_SamplingProfiler.c \
161 native/dalvik_system_VMDebug.c \
162 native/dalvik_system_VMRuntime.c \
163 native/dalvik_system_VMStack.c \
164 native/dalvik_system_Zygote.c \
165 native/java_lang_Class.c \
166 native/java_lang_Object.c \
167 native/java_lang_Runtime.c \
168 native/java_lang_String.c \
169 native/java_lang_System.c \
170 native/java_lang_SystemProperties.c \
171 native/java_lang_Throwable.c \
172 native/java_lang_VMClassLoader.c \
173 native/java_lang_VMThread.c \
174 native/java_lang_reflect_AccessibleObject.c \
175 native/java_lang_reflect_Array.c \
176 native/java_lang_reflect_Constructor.c \
177 native/java_lang_reflect_Field.c \
178 native/java_lang_reflect_Method.c \
179 native/java_lang_reflect_Proxy.c \
180 native/java_security_AccessController.c \
181 native/java_util_concurrent_atomic_AtomicLong.c \
182 native/org_apache_harmony_dalvik_NativeTestTarget.c \
183 native/org_apache_harmony_dalvik_ddmc_DdmServer.c \
184 native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.c \
185 native/sun_misc_Unsafe.c \
Bob Lee2fe146a2009-09-10 00:36:29 +0200186 native/SystemThread.c \
Dan Bornstein42122412009-07-21 16:08:39 -0700187 oo/AccessCheck.c \
188 oo/Array.c \
189 oo/Class.c \
190 oo/Object.c \
191 oo/Resolve.c \
192 oo/TypeCheck.c \
193 reflect/Annotation.c \
194 reflect/Proxy.c \
195 reflect/Reflect.c \
196 test/AtomicSpeed.c \
197 test/TestHash.c \
198 test/TestIndirectRefTable.c
199
Ben Cheng3f02aa42009-08-14 13:52:09 -0700200WITH_JIT := $(strip $(WITH_JIT))
Dan Bornstein42122412009-07-21 16:08:39 -0700201
202ifeq ($(WITH_JIT),true)
Dan Bornstein42122412009-07-21 16:08:39 -0700203 LOCAL_CFLAGS += -DWITH_JIT
204 LOCAL_SRC_FILES += \
205 ../dexdump/OpCodeNames.c \
206 compiler/Compiler.c \
207 compiler/Frontend.c \
208 compiler/Utility.c \
209 compiler/IntermediateRep.c \
Ben Cheng4238ec22009-08-24 16:32:22 -0700210 compiler/Dataflow.c \
211 compiler/Loop.c \
Bill Buzbee1465db52009-09-23 17:17:35 -0700212 compiler/Ralloc.c \
Dan Bornstein42122412009-07-21 16:08:39 -0700213 interp/Jit.c
214endif
215
Dan Bornstein42122412009-07-21 16:08:39 -0700216WITH_HPROF := $(strip $(WITH_HPROF))
217ifeq ($(WITH_HPROF),)
218 WITH_HPROF := true
219endif
220ifeq ($(WITH_HPROF),true)
221 LOCAL_SRC_FILES += \
222 hprof/Hprof.c \
223 hprof/HprofClass.c \
224 hprof/HprofHeap.c \
225 hprof/HprofOutput.c \
226 hprof/HprofString.c
227 LOCAL_CFLAGS += -DWITH_HPROF=1
228
Dan Bornstein42122412009-07-21 16:08:39 -0700229 ifeq ($(strip $(WITH_HPROF_STACK)),true)
230 LOCAL_SRC_FILES += \
231 hprof/HprofStack.c \
232 hprof/HprofStackFrame.c
233 LOCAL_CFLAGS += -DWITH_HPROF_STACK=1
234 endif # WITH_HPROF_STACK
235endif # WITH_HPROF
236
237ifeq ($(strip $(DVM_TRACK_HEAP_MARKING)),true)
238 LOCAL_CFLAGS += -DDVM_TRACK_HEAP_MARKING=1
239endif
240
241LOCAL_C_INCLUDES += \
242 $(JNI_H_INCLUDE) \
243 dalvik \
244 dalvik/vm \
245 external/zlib \
246 $(KERNEL_HEADERS)
247
248
249ifeq ($(dvm_simulator),true)
250 LOCAL_LDLIBS += -lpthread -ldl
251 ifeq ($(HOST_OS),linux)
252 # need this for clock_gettime() in profiling
253 LOCAL_LDLIBS += -lrt
254 endif
255else
256 ifeq ($(dvm_os),linux)
257 LOCAL_SHARED_LIBRARIES += libdl
258 endif
259endif
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
266 MTERP_ARCH_KNOWN := true
267 # Select architecture-specific sources (armv4t, armv5te etc.)
268 LOCAL_SRC_FILES += \
269 arch/arm/CallOldABI.S \
270 arch/arm/CallEABI.S \
271 arch/arm/HintsEABI.c \
272 mterp/out/InterpC-$(dvm_arch_variant).c.arm \
273 mterp/out/InterpAsm-$(dvm_arch_variant).S
274
275 ifeq ($(WITH_JIT),true)
276 LOCAL_SRC_FILES += \
Ben Cheng5d90c202009-11-22 23:31:11 -0800277 compiler/codegen/arm/RallocUtil.c \
278 compiler/codegen/arm/$(dvm_arch_variant)/Codegen.c \
Ben Cheng24ac5372009-12-16 13:15:53 -0800279 compiler/codegen/arm/$(dvm_arch_variant)/CallingConvention.S \
Dan Bornstein42122412009-07-21 16:08:39 -0700280 compiler/codegen/arm/Assemble.c \
281 compiler/codegen/arm/ArchUtility.c \
282 compiler/codegen/arm/LocalOptimizations.c \
283 compiler/codegen/arm/GlobalOptimizations.c \
284 compiler/template/out/CompilerTemplateAsm-$(dvm_arch_variant).S
285 endif
286endif
287
288ifeq ($(dvm_arch),x86)
289 ifeq ($(dvm_os),linux)
290 MTERP_ARCH_KNOWN := true
291 LOCAL_SRC_FILES += \
Johnnie Birch22d404a2009-04-06 15:26:13 -0700292 arch/$(dvm_arch_variant)/Call386ABI.S \
293 arch/$(dvm_arch_variant)/Hints386ABI.c \
294 mterp/out/InterpC-$(dvm_arch_variant).c \
295 mterp/out/InterpAsm-$(dvm_arch_variant).S
Dan Bornstein42122412009-07-21 16:08:39 -0700296 endif
297endif
298
299ifeq ($(dvm_arch),sh)
300 MTERP_ARCH_KNOWN := true
301 LOCAL_SRC_FILES += \
302 arch/sh/CallSH4ABI.S \
303 arch/generic/Hints.c \
304 mterp/out/InterpC-allstubs.c \
305 mterp/out/InterpAsm-allstubs.S
306endif
307
308ifeq ($(MTERP_ARCH_KNOWN),false)
309 # unknown architecture, try to use FFI
310 LOCAL_C_INCLUDES += external/libffi/$(dvm_os)-$(dvm_arch)
Dan Bornstein93194e92009-08-24 17:50:34 -0700311
312 ifeq ($(dvm_os)-$(dvm_arch),darwin-x86)
313 # OSX includes libffi, so just make the linker aware of it directly.
314 LOCAL_LDLIBS += -lffi
315 else
316 LOCAL_SHARED_LIBRARIES += libffi
317 endif
Dan Bornstein42122412009-07-21 16:08:39 -0700318
319 LOCAL_SRC_FILES += \
320 arch/generic/Call.c \
321 arch/generic/Hints.c \
322 mterp/out/InterpC-allstubs.c
323
324 # The following symbols are usually defined in the asm file, but
325 # since we don't have an asm file in this case, we instead just
326 # peg them at 0 here, and we add an #ifdef'able define for good
327 # measure, too.
328 LOCAL_CFLAGS += -DdvmAsmInstructionStart=0 -DdvmAsmInstructionEnd=0 \
329 -DdvmAsmSisterStart=0 -DdvmAsmSisterEnd=0 -DDVM_NO_ASM_INTERP=1
330endif
Ben Chengc3b92b22010-01-26 16:46:15 -0800331
332ifeq ($(TEST_VM_IN_ECLAIR),true)
333 LOCAL_CFLAGS += -DTEST_VM_IN_ECLAIR
334endif