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# Android.mk for Dalvik VM.  If you enable or disable optional features here,
17# rebuild the VM with "make clean-libdvm && make -j4 libdvm".
18#
19LOCAL_PATH:= $(call my-dir)
20include $(CLEAR_VARS)
21
22
23#
24# Compiler defines.
25#
26LOCAL_CFLAGS += -fstrict-aliasing -Wstrict-aliasing=2 -fno-align-jumps
27
28#
29# Optional features.  These may impact the size or performance of the VM.
30#
31LOCAL_CFLAGS += -DWITH_PROFILER -DWITH_DEBUGGER
32
33# 0=full cache, 1/2=reduced, 3=no cache
34LOCAL_CFLAGS += -DDVM_RESOLVER_CACHE=0
35
36ifeq ($(WITH_DEADLOCK_PREDICTION),true)
37  LOCAL_CFLAGS += -DWITH_DEADLOCK_PREDICTION
38  WITH_MONITOR_TRACKING := true
39endif
40ifeq ($(WITH_MONITOR_TRACKING),true)
41  LOCAL_CFLAGS += -DWITH_MONITOR_TRACKING
42endif
43
44# Make DEBUG_DALVIK_VM default to true when building the simulator.
45ifeq ($(TARGET_SIMULATOR),true)
46  ifeq ($(strip $(DEBUG_DALVIK_VM)),)
47    DEBUG_DALVIK_VM := true
48  endif
49endif
50
51ifeq ($(strip $(DEBUG_DALVIK_VM)),true)
52  #
53  # "Debug" profile:
54  # - debugger enabled
55  # - profiling enabled
56  # - tracked-reference verification enabled
57  # - allocation limits enabled
58  # - GDB helpers enabled
59  # - LOGV
60  # - assert()  (NDEBUG is handled in the build system)
61  #
62  LOCAL_CFLAGS += -DWITH_INSTR_CHECKS -DWITH_EXTRA_OBJECT_VALIDATION
63  LOCAL_CFLAGS += -DWITH_TRACKREF_CHECKS
64  LOCAL_CFLAGS += -DWITH_ALLOC_LIMITS
65  #LOCAL_CFLAGS += -DCHECK_MUTEX
66  #LOCAL_CFLAGS += -DPROFILE_FIELD_ACCESS
67  LOCAL_CFLAGS += -DDVM_SHOW_EXCEPTION=3
68  # add some extra stuff to make it easier to examine with GDB
69  LOCAL_CFLAGS += -DEASY_GDB
70else  # !DALVIK_VM_DEBUG
71  #
72  # "Performance" profile:
73  # - all development features disabled
74  # - compiler optimizations enabled (redundant for "release" builds)
75  # - (debugging and profiling still enabled)
76  #
77  #LOCAL_CFLAGS += -DNDEBUG -DLOG_NDEBUG=1
78  # "-O2" is redundant for device (release) but useful for sim (debug)
79  #LOCAL_CFLAGS += -O2 -Winline
80  LOCAL_CFLAGS += -DDVM_SHOW_EXCEPTION=1
81  # if you want to try with assertions on the device, add:
82  #LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1 -DLOG_NDEBUG=1 -DWITH_DALVIK_ASSERT
83endif  # !DALVIK_VM_DEBUG
84
85# bug hunting: checksum and verify interpreted stack when making JNI calls
86#LOCAL_CFLAGS += -DWITH_JNI_STACK_CHECK
87
88LOCAL_SRC_FILES := \
89	AllocTracker.c \
90	AtomicCache.c \
91	CheckJni.c \
92	Ddm.c \
93	Debugger.c \
94	DvmDex.c \
95	Exception.c \
96	Hash.c \
97	Init.c \
98	InlineNative.c.arm \
99	Inlines.c \
100	Intern.c \
101	Jni.c \
102	JarFile.c \
103	LinearAlloc.c \
104	Misc.c.arm \
105	Native.c \
106	PointerSet.c \
107	Profile.c \
108	Properties.c \
109	RawDexFile.c \
110	ReferenceTable.c \
111	SignalCatcher.c \
112	StdioConverter.c \
113	Sync.c \
114	Thread.c \
115	UtfString.c \
116	alloc/clz.c.arm \
117	alloc/Alloc.c \
118	alloc/HeapBitmap.c.arm \
119	alloc/HeapDebug.c \
120	alloc/HeapSource.c \
121	alloc/HeapTable.c \
122	alloc/HeapWorker.c \
123	alloc/Heap.c.arm \
124	alloc/MarkSweep.c.arm \
125	alloc/DdmHeap.c \
126	analysis/CodeVerify.c \
127	analysis/DexOptimize.c \
128	analysis/DexVerify.c \
129	analysis/ReduceConstants.c \
130	analysis/RegisterMap.c \
131	analysis/VerifySubs.c \
132	interp/Interp.c.arm \
133	interp/Stack.c \
134	jdwp/ExpandBuf.c \
135	jdwp/JdwpAdb.c \
136	jdwp/JdwpConstants.c \
137	jdwp/JdwpEvent.c \
138	jdwp/JdwpHandler.c \
139	jdwp/JdwpMain.c \
140	jdwp/JdwpSocket.c \
141	mterp/Mterp.c.arm \
142	mterp/out/InterpC-portstd.c.arm \
143	mterp/out/InterpC-portdbg.c.arm \
144	native/InternalNative.c \
145	native/dalvik_system_DexFile.c \
146	native/dalvik_system_VMDebug.c \
147	native/dalvik_system_VMRuntime.c \
148	native/dalvik_system_VMStack.c \
149	native/dalvik_system_Zygote.c \
150	native/java_lang_Class.c \
151	native/java_lang_Object.c \
152	native/java_lang_Runtime.c \
153	native/java_lang_String.c \
154	native/java_lang_System.c \
155	native/java_lang_SystemProperties.c \
156	native/java_lang_Throwable.c \
157	native/java_lang_VMClassLoader.c \
158	native/java_lang_VMThread.c \
159	native/java_lang_reflect_AccessibleObject.c \
160	native/java_lang_reflect_Array.c \
161	native/java_lang_reflect_Constructor.c \
162	native/java_lang_reflect_Field.c \
163	native/java_lang_reflect_Method.c \
164	native/java_lang_reflect_Proxy.c \
165	native/java_security_AccessController.c \
166	native/java_util_concurrent_atomic_AtomicLong.c \
167	native/org_apache_harmony_dalvik_NativeTestTarget.c \
168	native/org_apache_harmony_dalvik_ddmc_DdmServer.c \
169	native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.c \
170	native/sun_misc_Unsafe.c \
171	oo/AccessCheck.c \
172	oo/Array.c \
173	oo/Class.c \
174	oo/Object.c \
175	oo/Resolve.c \
176	oo/TypeCheck.c \
177	reflect/Annotation.c \
178	reflect/Proxy.c \
179	reflect/Reflect.c \
180	test/TestHash.c
181
182WITH_HPROF := $(strip $(WITH_HPROF))
183ifeq ($(WITH_HPROF),)
184  WITH_HPROF := true
185endif
186ifeq ($(WITH_HPROF),true)
187  LOCAL_SRC_FILES += \
188	hprof/Hprof.c \
189	hprof/HprofClass.c \
190	hprof/HprofHeap.c \
191	hprof/HprofOutput.c \
192	hprof/HprofString.c
193  LOCAL_CFLAGS += -DWITH_HPROF=1
194
195  ifeq ($(strip $(WITH_HPROF_UNREACHABLE)),true)
196    LOCAL_CFLAGS += -DWITH_HPROF_UNREACHABLE=1
197  endif
198
199  ifeq ($(strip $(WITH_HPROF_STACK)),true)
200    LOCAL_SRC_FILES += \
201	hprof/HprofStack.c \
202	hprof/HprofStackFrame.c
203    LOCAL_CFLAGS += -DWITH_HPROF_STACK=1
204  endif # WITH_HPROF_STACK
205endif   # WITH_HPROF
206
207ifeq ($(strip $(DVM_TRACK_HEAP_MARKING)),true)
208  LOCAL_CFLAGS += -DDVM_TRACK_HEAP_MARKING=1
209endif
210
211LOCAL_C_INCLUDES += \
212	$(JNI_H_INCLUDE) \
213	dalvik \
214	dalvik/vm \
215	external/zlib \
216	$(KERNEL_HEADERS)
217
218
219ifeq ($(TARGET_SIMULATOR),true)
220  LOCAL_LDLIBS += -lpthread -ldl
221  ifeq ($(HOST_OS),linux)
222    # need this for clock_gettime() in profiling
223    LOCAL_LDLIBS += -lrt
224  endif
225else
226  LOCAL_SHARED_LIBRARIES += libdl
227endif
228
229ifeq ($(TARGET_ARCH),arm)
230  LOCAL_SRC_FILES += \
231		arch/arm/CallOldABI.S \
232		arch/arm/CallEABI.S \
233		arch/arm/HintsEABI.c
234  # TODO: select sources for ARMv4 vs. ARMv5TE
235  LOCAL_SRC_FILES += \
236		mterp/out/InterpC-armv5te.c.arm \
237		mterp/out/InterpAsm-armv5te.S
238  LOCAL_SHARED_LIBRARIES += libdl
239else
240  ifeq ($(TARGET_ARCH),x86)
241    LOCAL_SRC_FILES += \
242		arch/x86/Call386ABI.S \
243		arch/x86/Hints386ABI.c
244    LOCAL_SRC_FILES += \
245		mterp/out/InterpC-x86.c \
246		mterp/out/InterpAsm-x86.S
247  else
248	# unknown architecture, try to use FFI
249    LOCAL_C_INCLUDES += external/libffi/$(TARGET_OS)-$(TARGET_ARCH)
250    LOCAL_SRC_FILES += \
251		arch/generic/Call.c \
252		arch/generic/Hints.c
253    LOCAL_SHARED_LIBRARIES += libffi
254	
255    LOCAL_SRC_FILES += \
256		mterp/out/InterpC-allstubs.c \
257		mterp/out/InterpAsm-allstubs.S
258  endif
259endif
260
261
262LOCAL_MODULE := libdvm
263
264LOCAL_SHARED_LIBRARIES += \
265	liblog \
266	libcutils \
267	libnativehelper \
268	libz
269
270LOCAL_STATIC_LIBRARIES += \
271	libdex
272
273include $(BUILD_SHARED_LIBRARY)
274