OSDN Git Service

am 119d6541: resolved conflicts for merge of ab84215a to jb-mr1-dev-plus-aosp
[android-x86/dalvik.git] / vm / Android.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 # Android.mk for Dalvik VM.
17 #
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.
21 #
22 # If you enable or disable optional features here (or in Dvm.mk),
23 # rebuild the VM with:
24 #
25 #  make clean-libdvm clean-libdvm_assert clean-libdvm_sv clean-libdvm_interp
26 #  make -j4 libdvm
27 #
28
29 LOCAL_PATH:= $(call my-dir)
30
31 #
32 # Build for the target (device).
33 #
34
35 ifeq ($(TARGET_CPU_SMP),true)
36     target_smp_flag := -DANDROID_SMP=1
37 else
38     target_smp_flag := -DANDROID_SMP=0
39 endif
40 host_smp_flag := -DANDROID_SMP=1
41
42 # Build the installed version (libdvm.so) first
43 include $(LOCAL_PATH)/ReconfigureDvm.mk
44
45 # Overwrite default settings
46 LOCAL_MODULE_TAGS := optional
47 LOCAL_MODULE := libdvm
48 LOCAL_CFLAGS += $(target_smp_flag)
49
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))
56 endif
57
58 # TODO: split out the asflags.
59 LOCAL_ASFLAGS := $(LOCAL_CFLAGS)
60
61 include $(BUILD_SHARED_LIBRARY)
62
63 # If WITH_JIT is configured, build multiple versions of libdvm.so to facilitate
64 # correctness/performance bugs triage
65 ifeq ($(WITH_JIT),true)
66
67     # Derivation #1
68     # Enable assert and JIT tuning
69     include $(LOCAL_PATH)/ReconfigureDvm.mk
70
71     # Enable assertions and JIT-tuning
72     LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1 -DLOG_NDEBUG=1 -DWITH_DALVIK_ASSERT \
73                     -DWITH_JIT_TUNING $(target_smp_flag)
74     # TODO: split out the asflags.
75     LOCAL_ASFLAGS := $(LOCAL_CFLAGS)
76     LOCAL_MODULE := libdvm_assert
77     include $(BUILD_SHARED_LIBRARY)
78
79   ifneq ($(dvm_arch),mips)    # MIPS support for self-verification is incomplete
80     # Derivation #2
81     # Enable assert and self-verification
82     include $(LOCAL_PATH)/ReconfigureDvm.mk
83
84     # Enable assertions and JIT self-verification
85     LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1 -DLOG_NDEBUG=1 -DWITH_DALVIK_ASSERT \
86                     -DWITH_SELF_VERIFICATION $(target_smp_flag)
87     # TODO: split out the asflags.
88     LOCAL_ASFLAGS := $(LOCAL_CFLAGS)
89     LOCAL_MODULE := libdvm_sv
90     include $(BUILD_SHARED_LIBRARY)
91   endif # dvm_arch!=mips
92
93     # Derivation #3
94     # Compile out the JIT
95     WITH_JIT := false
96     include $(LOCAL_PATH)/ReconfigureDvm.mk
97
98     LOCAL_CFLAGS += $(target_smp_flag)
99     # TODO: split out the asflags.
100     LOCAL_ASFLAGS := $(LOCAL_CFLAGS)
101     LOCAL_MODULE := libdvm_interp
102     include $(BUILD_SHARED_LIBRARY)
103
104   ifeq ($(dvm_arch),x86)    # For x86, we enable JIT on host too
105     # restore WITH_JIT = true for host dalvik build
106     WITH_JIT := true
107   endif # dvm_arch==x86
108 endif
109
110 #
111 # Build for the host.
112 #
113
114 ifeq ($(WITH_HOST_DALVIK),true)
115
116     include $(CLEAR_VARS)
117
118     # Variables used in the included Dvm.mk.
119     dvm_os := $(HOST_OS)
120     dvm_arch := $(HOST_ARCH)
121     # Note: HOST_ARCH_VARIANT isn't defined.
122     dvm_arch_variant := $(HOST_ARCH)
123
124     # We always want the x86 JIT.
125     ifeq ($(dvm_arch),x86)
126         WITH_JIT := true
127     endif
128
129     include $(LOCAL_PATH)/Dvm.mk
130
131     LOCAL_SHARED_LIBRARIES += libcrypto libssl libicuuc libicui18n
132
133     LOCAL_LDLIBS := -lpthread -ldl
134     ifeq ($(HOST_OS),linux)
135       # need this for clock_gettime() in profiling
136       LOCAL_LDLIBS += -lrt
137     endif
138
139     # Build as a WHOLE static library so dependencies are available at link
140     # time. When building this target as a regular static library, certain
141     # dependencies like expat are not found by the linker.
142     LOCAL_WHOLE_STATIC_LIBRARIES += libexpat libcutils libdex liblog libz
143
144     # The libffi from the source tree should never be used by host builds.
145     # The recommendation is that host builds should always either
146     # have sufficient custom code so that libffi isn't needed at all,
147     # or they should use the platform's provided libffi. So, if the common
148     # build rules decided to include it, axe it back out here.
149     ifneq (,$(findstring libffi,$(LOCAL_SHARED_LIBRARIES)))
150         LOCAL_SHARED_LIBRARIES := \
151             $(patsubst libffi, ,$(LOCAL_SHARED_LIBRARIES))
152     endif
153
154     LOCAL_CFLAGS += $(host_smp_flag)
155     # TODO: split out the asflags.
156     LOCAL_ASFLAGS := $(LOCAL_CFLAGS)
157     LOCAL_MODULE_TAGS := optional
158     LOCAL_MODULE := libdvm
159
160     include $(BUILD_HOST_SHARED_LIBRARY)
161
162     # Copy the dalvik shell script to the host's bin directory
163     include $(CLEAR_VARS)
164     LOCAL_IS_HOST_MODULE := true
165     LOCAL_MODULE_TAGS := optional
166     LOCAL_MODULE_CLASS := EXECUTABLES
167     LOCAL_MODULE := dalvik
168     include $(BUILD_SYSTEM)/base_rules.mk
169 $(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/dalvik | $(ACP)
170         @echo "Copy: $(PRIVATE_MODULE) ($@)"
171         $(copy-file-to-new-target)
172         $(hide) chmod 755 $@
173
174 endif