OSDN Git Service

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