OSDN Git Service

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