Android.mk revision 311886c6c6fcd3b531531f592d56caab5e2a259c
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
29LOCAL_PATH:= $(call my-dir)
30
31#
32# Build for the target (device).
33#
34
35ifeq ($(TARGET_CPU_SMP),true)
36    target_smp_flag := -DANDROID_SMP=1
37else
38    target_smp_flag := -DANDROID_SMP=0
39endif
40host_smp_flag := -DANDROID_SMP=1
41
42# Build the installed version (libdvm.so) first
43include $(LOCAL_PATH)/ReconfigureDvm.mk
44
45# Overwrite default settings
46LOCAL_MODULE_TAGS := optional
47LOCAL_MODULE := libdvm
48LOCAL_CFLAGS += $(target_smp_flag)
49include $(BUILD_SHARED_LIBRARY)
50
51# If WITH_JIT is configured, build multiple versions of libdvm.so to facilitate
52# correctness/performance bugs triage
53ifeq ($(WITH_JIT),true)
54
55    # Derivation #1
56    # Enable assert and JIT tuning
57    include $(LOCAL_PATH)/ReconfigureDvm.mk
58
59    # Enable assertions and JIT-tuning
60    LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1 -DLOG_NDEBUG=1 -DWITH_DALVIK_ASSERT \
61                    -DWITH_JIT_TUNING $(target_smp_flag)
62    LOCAL_MODULE := libdvm_assert
63    include $(BUILD_SHARED_LIBRARY)
64
65    # Derivation #2
66    # Enable assert and self-verification
67    include $(LOCAL_PATH)/ReconfigureDvm.mk
68
69    # Enable assertions and JIT self-verification
70    LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1 -DLOG_NDEBUG=1 -DWITH_DALVIK_ASSERT \
71                    -DWITH_SELF_VERIFICATION $(target_smp_flag)
72
73    LOCAL_C_INCLUDES += bionic/libc/kernel/common
74
75    LOCAL_MODULE := libdvm_sv
76    include $(BUILD_SHARED_LIBRARY)
77
78    # Derivation #3
79    # Compile out the JIT
80    WITH_JIT := false
81    include $(LOCAL_PATH)/ReconfigureDvm.mk
82
83    LOCAL_CFLAGS += $(target_smp_flag)
84    LOCAL_MODULE := libdvm_interp
85    include $(BUILD_SHARED_LIBRARY)
86
87endif
88
89#
90# Build for the host.
91#
92
93ifeq ($(WITH_HOST_DALVIK),true)
94
95    include $(CLEAR_VARS)
96
97    # Variables used in the included Dvm.mk.
98    dvm_os := $(HOST_OS)
99    dvm_arch := $(HOST_ARCH)
100    # Note: HOST_ARCH_VARIANT isn't defined.
101    dvm_arch_variant := $(HOST_ARCH)
102
103    WITH_JIT := false
104    include $(LOCAL_PATH)/Dvm.mk
105
106    LOCAL_SHARED_LIBRARIES += libcrypto libssl libicuuc libicui18n
107
108    LOCAL_LDLIBS := -lpthread -ldl
109    ifeq ($(HOST_OS),linux)
110      # need this for clock_gettime() in profiling
111      LOCAL_LDLIBS += -lrt
112    endif
113
114    # Build as a WHOLE static library so dependencies are available at link
115    # time. When building this target as a regular static library, certain
116    # dependencies like expat are not found by the linker.
117    LOCAL_WHOLE_STATIC_LIBRARIES += libexpat libcutils libdex liblog libnativehelper libz
118
119    # The libffi from the source tree should never be used by host builds.
120    # The recommendation is that host builds should always either
121    # have sufficient custom code so that libffi isn't needed at all,
122    # or they should use the platform's provided libffi. So, if the common
123    # build rules decided to include it, axe it back out here.
124    ifneq (,$(findstring libffi,$(LOCAL_SHARED_LIBRARIES)))
125        LOCAL_SHARED_LIBRARIES := \
126            $(patsubst libffi, ,$(LOCAL_SHARED_LIBRARIES))
127    endif
128
129    LOCAL_C_INCLUDES += bionic/libc/kernel/common
130
131    LOCAL_CFLAGS += $(host_smp_flag)
132    LOCAL_MODULE_TAGS := optional
133    LOCAL_MODULE := libdvm
134
135    include $(BUILD_HOST_SHARED_LIBRARY)
136
137    # Copy the dalvik shell script to the host's bin directory
138    include $(CLEAR_VARS)
139    LOCAL_IS_HOST_MODULE := true
140    LOCAL_MODULE_TAGS := optional
141    LOCAL_MODULE_CLASS := EXECUTABLES
142    LOCAL_MODULE := dalvik
143    include $(BUILD_SYSTEM)/base_rules.mk
144$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/dalvik | $(ACP)
145	@echo "Copy: $(PRIVATE_MODULE) ($@)"
146	$(copy-file-to-new-target)
147	$(hide) chmod 755 $@
148
149endif
150