Dvm.mk revision 5fac7a456f1e53650c0044f1dff99747976bee2a
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#
27LOCAL_CFLAGS += -fstrict-aliasing -Wstrict-aliasing=2 -fno-align-jumps
28LOCAL_CFLAGS += -Wall -Wextra -Wno-unused-parameter -Wc++-compat
29LOCAL_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.
37dvm_make_debug_vm := false
38ifeq ($(strip $(DEBUG_DALVIK_VM)),)
39  ifeq ($(dvm_simulator),true)
40    dvm_make_debug_vm := true
41  endif
42else
43  dvm_make_debug_vm := $(DEBUG_DALVIK_VM)
44endif
45
46ifeq ($(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 += -DPROFILE_FIELD_ACCESS
63  LOCAL_CFLAGS += -DDVM_SHOW_EXCEPTION=3
64  # add some extra stuff to make it easier to examine with GDB
65  LOCAL_CFLAGS += -DEASY_GDB
66  # overall config may be for a "release" build, so reconfigure these
67  LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1 -DLOG_NDEBUG=1 -DWITH_DALVIK_ASSERT
68else  # !dvm_make_debug_vm
69  #
70  # "Performance" profile:
71  # - all development features disabled
72  # - compiler optimizations enabled (redundant for "release" builds)
73  # - (debugging and profiling still enabled)
74  #
75  #LOCAL_CFLAGS += -DNDEBUG -DLOG_NDEBUG=1
76  # "-O2" is redundant for device (release) but useful for sim (debug)
77  #LOCAL_CFLAGS += -O2 -Winline
78  #LOCAL_CFLAGS += -DWITH_EXTRA_OBJECT_VALIDATION
79  LOCAL_CFLAGS += -DDVM_SHOW_EXCEPTION=1
80  # if you want to try with assertions on the device, add:
81  #LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1 -DLOG_NDEBUG=1 -DWITH_DALVIK_ASSERT
82endif  # !dvm_make_debug_vm
83
84# bug hunting: checksum and verify interpreted stack when making JNI calls
85#LOCAL_CFLAGS += -DWITH_JNI_STACK_CHECK
86
87LOCAL_SRC_FILES := \
88	AllocTracker.c \
89	Atomic.c.arm \
90	AtomicCache.c \
91	BitVector.c.arm \
92	CheckJni.c \
93	Ddm.c \
94	Debugger.c \
95	DvmDex.c \
96	Exception.c \
97	Hash.c \
98	IndirectRefTable.c.arm \
99	Init.c \
100	InitRefs.c \
101	InlineNative.c.arm \
102	Inlines.c \
103	Intern.c \
104	Jni.c \
105	JarFile.c \
106	LinearAlloc.c \
107	Misc.c \
108	Native.c \
109	PointerSet.c \
110	Profile.c \
111	Properties.c \
112	RawDexFile.c \
113	ReferenceTable.c \
114	SignalCatcher.c \
115	StdioConverter.c \
116	Sync.c \
117	Thread.c \
118	UtfString.c \
119	alloc/Alloc.c \
120	alloc/CardTable.c \
121	alloc/HeapBitmap.c.arm \
122	alloc/HeapDebug.c \
123	alloc/HeapTable.c \
124	alloc/HeapWorker.c \
125	alloc/Heap.c.arm \
126	alloc/DdmHeap.c \
127	alloc/Verify.c \
128	alloc/Visit.c \
129	analysis/CodeVerify.c \
130	analysis/DexPrepare.c \
131	analysis/DexVerify.c \
132	analysis/Liveness.c \
133	analysis/Optimize.c \
134	analysis/RegisterMap.c \
135	analysis/VerifySubs.c \
136	analysis/VfyBasicBlock.c \
137	hprof/Hprof.c \
138	hprof/HprofClass.c \
139	hprof/HprofHeap.c \
140	hprof/HprofOutput.c \
141	hprof/HprofString.c \
142	interp/Interp.c.arm \
143	interp/Stack.c \
144	jdwp/ExpandBuf.c \
145	jdwp/JdwpAdb.c \
146	jdwp/JdwpConstants.c \
147	jdwp/JdwpEvent.c \
148	jdwp/JdwpHandler.c \
149	jdwp/JdwpMain.c \
150	jdwp/JdwpSocket.c \
151	mterp/Mterp.c.arm \
152	mterp/out/InterpC-portstd.c.arm \
153	mterp/out/InterpC-portdbg.c.arm \
154	native/InternalNative.c \
155	native/dalvik_bytecode_OpcodeInfo.c \
156	native/dalvik_system_DexFile.c \
157	native/dalvik_system_VMDebug.c \
158	native/dalvik_system_VMRuntime.c \
159	native/dalvik_system_VMStack.c \
160	native/dalvik_system_Zygote.c \
161	native/java_lang_Class.c \
162	native/java_lang_Double.c \
163	native/java_lang_Float.c \
164	native/java_lang_Math.c \
165	native/java_lang_Object.c \
166	native/java_lang_Runtime.c \
167	native/java_lang_String.c \
168	native/java_lang_System.c \
169	native/java_lang_Throwable.c \
170	native/java_lang_VMClassLoader.c \
171	native/java_lang_VMThread.c \
172	native/java_lang_reflect_AccessibleObject.c \
173	native/java_lang_reflect_Array.c \
174	native/java_lang_reflect_Constructor.c \
175	native/java_lang_reflect_Field.c \
176	native/java_lang_reflect_Method.c \
177	native/java_lang_reflect_Proxy.c \
178	native/java_security_AccessController.c \
179	native/java_util_concurrent_atomic_AtomicLong.c \
180	native/org_apache_harmony_dalvik_NativeTestTarget.c \
181	native/org_apache_harmony_dalvik_ddmc_DdmServer.c \
182	native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.c \
183	native/sun_misc_Unsafe.c \
184	oo/AccessCheck.c \
185	oo/Array.c \
186	oo/Class.c \
187	oo/Object.c \
188	oo/Resolve.c \
189	oo/TypeCheck.c \
190	reflect/Annotation.c \
191	reflect/Proxy.c \
192	reflect/Reflect.c \
193	test/AtomicTest.c.arm \
194	test/TestHash.c \
195	test/TestIndirectRefTable.c
196
197WITH_COPYING_GC := $(strip $(WITH_COPYING_GC))
198
199ifeq ($(WITH_COPYING_GC),true)
200  LOCAL_CFLAGS += -DWITH_COPYING_GC
201  LOCAL_SRC_FILES += \
202	alloc/Copying.c.arm
203else
204  LOCAL_SRC_FILES += \
205	alloc/HeapSource.c \
206	alloc/MarkSweep.c.arm
207endif
208
209WITH_JIT := $(strip $(WITH_JIT))
210
211ifeq ($(WITH_JIT),true)
212  LOCAL_CFLAGS += -DWITH_JIT
213  LOCAL_SRC_FILES += \
214	compiler/Compiler.c \
215	compiler/Frontend.c \
216	compiler/Utility.c \
217	compiler/InlineTransformation.c \
218	compiler/IntermediateRep.c \
219	compiler/Dataflow.c \
220	compiler/SSATransformation.c \
221	compiler/Loop.c \
222	compiler/Ralloc.c \
223	interp/Jit.c
224endif
225
226LOCAL_C_INCLUDES += \
227	$(JNI_H_INCLUDE) \
228	dalvik \
229	dalvik/vm \
230	external/zlib \
231	$(KERNEL_HEADERS)
232
233
234ifeq ($(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
240endif
241
242MTERP_ARCH_KNOWN := false
243
244ifeq ($(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.c \
254		mterp/out/InterpC-$(dvm_arch_variant).c.arm \
255		mterp/out/InterpAsm-$(dvm_arch_variant).S
256
257  ifeq ($(WITH_JIT),true)
258    LOCAL_SRC_FILES += \
259		compiler/codegen/RallocUtil.c \
260		compiler/codegen/arm/$(dvm_arch_variant)/Codegen.c \
261		compiler/codegen/arm/$(dvm_arch_variant)/CallingConvention.S \
262		compiler/codegen/arm/Assemble.c \
263		compiler/codegen/arm/ArchUtility.c \
264		compiler/codegen/arm/LocalOptimizations.c \
265		compiler/codegen/arm/GlobalOptimizations.c \
266		compiler/codegen/arm/ArmRallocUtil.c \
267		compiler/template/out/CompilerTemplateAsm-$(dvm_arch_variant).S
268  endif
269endif
270
271ifeq ($(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.c \
278		mterp/out/InterpC-$(dvm_arch_variant).c \
279		mterp/out/InterpAsm-$(dvm_arch_variant).S
280    ifeq ($(WITH_JIT),true)
281      LOCAL_SRC_FILES += \
282		compiler/codegen/x86/Assemble.c \
283		compiler/codegen/x86/ArchUtility.c \
284		compiler/codegen/x86/ia32/Codegen.c \
285		compiler/codegen/x86/ia32/CallingConvention.S \
286		compiler/template/out/CompilerTemplateAsm-ia32.S
287    endif
288  endif
289endif
290
291ifeq ($(dvm_arch),sh)
292  MTERP_ARCH_KNOWN := true
293  LOCAL_SRC_FILES += \
294		arch/sh/CallSH4ABI.S \
295		arch/generic/Hints.c \
296		mterp/out/InterpC-allstubs.c \
297		mterp/out/InterpAsm-allstubs.S
298endif
299
300ifeq ($(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.c \
313		arch/generic/Hints.c \
314		mterp/out/InterpC-allstubs.c
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
322endif
323