1 # Copyright (C) 2008 The Android Open Source Project
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
16 # Android.mk for Dalvik VM.
18 # This makefile builds both for host and target, and so the very large
19 # swath of common definitions are factored out into a separate file to
20 # minimize duplication.
22 # If you enable or disable optional features here (or in Dvm.mk),
23 # rebuild the VM with:
25 # make clean-libdvm clean-libdvm_assert clean-libdvm_sv clean-libdvm_interp
29 LOCAL_PATH:= $(call my-dir)
32 # Build for the target (device).
35 ifeq ($(TARGET_CPU_SMP),true)
36 target_smp_flag := -DANDROID_SMP=1
38 target_smp_flag := -DANDROID_SMP=0
40 host_smp_flag := -DANDROID_SMP=1
42 # Build the installed version (libdvm.so) first
44 include $(LOCAL_PATH)/ReconfigureDvm.mk
46 # Overwrite default settings
47 LOCAL_MODULE := libdvm
48 LOCAL_CFLAGS += $(target_smp_flag)
50 # Define WITH_ADDRESS_SANITIZER to build an ASan-instrumented version of the
51 # library in /system/lib/asan/libdvm.so.
52 ifneq ($(strip $(WITH_ADDRESS_SANITIZER)),)
53 LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/asan
54 LOCAL_ADDRESS_SANITIZER := true
55 LOCAL_CFLAGS := $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(LOCAL_CFLAGS))
58 # TODO: split out the asflags.
59 LOCAL_ASFLAGS := $(LOCAL_CFLAGS)
61 include $(BUILD_SHARED_LIBRARY)
64 # Enable assertions and JIT tuning
65 include $(LOCAL_PATH)/ReconfigureDvm.mk
66 LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1 -DLOG_NDEBUG=1 -DWITH_DALVIK_ASSERT \
67 -DWITH_JIT_TUNING $(target_smp_flag)
68 # TODO: split out the asflags.
69 LOCAL_ASFLAGS := $(LOCAL_CFLAGS)
70 LOCAL_MODULE := libdvm_assert
71 include $(BUILD_SHARED_LIBRARY)
73 ifneq ($(dvm_arch),mips) # MIPS support for self-verification is incomplete
76 # Enable assertions and JIT self-verification
77 include $(LOCAL_PATH)/ReconfigureDvm.mk
78 LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1 -DLOG_NDEBUG=1 -DWITH_DALVIK_ASSERT \
79 -DWITH_SELF_VERIFICATION $(target_smp_flag)
80 # TODO: split out the asflags.
81 LOCAL_ASFLAGS := $(LOCAL_CFLAGS)
82 LOCAL_MODULE := libdvm_sv
83 include $(BUILD_SHARED_LIBRARY)
85 endif # dvm_arch!=mips
90 include $(LOCAL_PATH)/ReconfigureDvm.mk
91 LOCAL_CFLAGS += $(target_smp_flag)
92 # TODO: split out the asflags.
93 LOCAL_ASFLAGS := $(LOCAL_CFLAGS)
94 LOCAL_MODULE := libdvm_interp
95 include $(BUILD_SHARED_LIBRARY)
102 ifeq ($(WITH_HOST_DALVIK),true)
104 include $(CLEAR_VARS)
106 # Variables used in the included Dvm.mk.
108 dvm_arch := $(HOST_ARCH)
109 # Note: HOST_ARCH_VARIANT isn't defined.
110 dvm_arch_variant := $(HOST_ARCH)
112 include $(LOCAL_PATH)/Dvm.mk
114 LOCAL_SHARED_LIBRARIES += libnativehelper libcrypto-host libssl-host libicuuc-host libicui18n-host
116 LOCAL_LDLIBS := -lpthread -ldl
117 ifeq ($(HOST_OS),linux)
118 # need this for clock_gettime() in profiling
122 # Build as a WHOLE static library so dependencies are available at link
123 # time. When building this target as a regular static library, certain
124 # dependencies like expat are not found by the linker.
125 LOCAL_WHOLE_STATIC_LIBRARIES += libexpat libcutils libdex liblog libz
127 # The libffi from the source tree should never be used by host builds.
128 # The recommendation is that host builds should always either
129 # have sufficient custom code so that libffi isn't needed at all,
130 # or they should use the platform's provided libffi. So, if the common
131 # build rules decided to include it, axe it back out here.
132 ifneq (,$(findstring libffi,$(LOCAL_SHARED_LIBRARIES)))
133 LOCAL_SHARED_LIBRARIES := \
134 $(patsubst libffi, ,$(LOCAL_SHARED_LIBRARIES))
137 LOCAL_CFLAGS += $(host_smp_flag)
138 # TODO: split out the asflags.
139 LOCAL_ASFLAGS := $(LOCAL_CFLAGS)
140 LOCAL_MODULE_TAGS := optional
141 LOCAL_MODULE := libdvm
143 include $(BUILD_HOST_SHARED_LIBRARY)
145 # Copy the dalvik shell script to the host's bin directory
146 include $(CLEAR_VARS)
147 LOCAL_IS_HOST_MODULE := true
148 LOCAL_MODULE_TAGS := optional
149 LOCAL_MODULE_CLASS := EXECUTABLES
150 LOCAL_MODULE := dalvik
151 include $(BUILD_SYSTEM)/base_rules.mk
152 $(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/dalvik | $(ACP)
153 @echo "Copy: $(PRIVATE_MODULE) ($@)"
154 $(copy-file-to-new-target)