Android.mk revision 86797a791d692f81def5c1b5f0918992c49ed122
1# 2# Copyright (C) 2011 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17LOCAL_PATH := $(call my-dir) 18 19include art/build/Android.common_build.mk 20 21LIBART_COMMON_SRC_FILES := \ 22 atomic.cc.arm \ 23 barrier.cc \ 24 base/allocator.cc \ 25 base/bit_vector.cc \ 26 base/hex_dump.cc \ 27 base/logging.cc \ 28 base/mutex.cc \ 29 base/scoped_flock.cc \ 30 base/stringpiece.cc \ 31 base/stringprintf.cc \ 32 base/timing_logger.cc \ 33 base/unix_file/fd_file.cc \ 34 base/unix_file/mapped_file.cc \ 35 base/unix_file/null_file.cc \ 36 base/unix_file/random_access_file_utils.cc \ 37 base/unix_file/string_file.cc \ 38 check_jni.cc \ 39 class_linker.cc \ 40 common_throws.cc \ 41 debugger.cc \ 42 dex_file.cc \ 43 dex_file_verifier.cc \ 44 dex_instruction.cc \ 45 elf_file.cc \ 46 gc/allocator/dlmalloc.cc \ 47 gc/allocator/rosalloc.cc \ 48 gc/accounting/card_table.cc \ 49 gc/accounting/gc_allocator.cc \ 50 gc/accounting/heap_bitmap.cc \ 51 gc/accounting/mod_union_table.cc \ 52 gc/accounting/remembered_set.cc \ 53 gc/accounting/space_bitmap.cc \ 54 gc/collector/concurrent_copying.cc \ 55 gc/collector/garbage_collector.cc \ 56 gc/collector/immune_region.cc \ 57 gc/collector/mark_compact.cc \ 58 gc/collector/mark_sweep.cc \ 59 gc/collector/partial_mark_sweep.cc \ 60 gc/collector/semi_space.cc \ 61 gc/collector/sticky_mark_sweep.cc \ 62 gc/gc_cause.cc \ 63 gc/heap.cc \ 64 gc/reference_processor.cc \ 65 gc/reference_queue.cc \ 66 gc/space/bump_pointer_space.cc \ 67 gc/space/dlmalloc_space.cc \ 68 gc/space/image_space.cc \ 69 gc/space/large_object_space.cc \ 70 gc/space/malloc_space.cc \ 71 gc/space/rosalloc_space.cc \ 72 gc/space/space.cc \ 73 gc/space/zygote_space.cc \ 74 hprof/hprof.cc \ 75 image.cc \ 76 indirect_reference_table.cc \ 77 instruction_set.cc \ 78 instrumentation.cc \ 79 intern_table.cc \ 80 interpreter/interpreter.cc \ 81 interpreter/interpreter_common.cc \ 82 interpreter/interpreter_switch_impl.cc \ 83 jdwp/jdwp_event.cc \ 84 jdwp/jdwp_expand_buf.cc \ 85 jdwp/jdwp_handler.cc \ 86 jdwp/jdwp_main.cc \ 87 jdwp/jdwp_request.cc \ 88 jdwp/jdwp_socket.cc \ 89 jdwp/object_registry.cc \ 90 jni_internal.cc \ 91 jobject_comparator.cc \ 92 mem_map.cc \ 93 memory_region.cc \ 94 mirror/art_field.cc \ 95 mirror/art_method.cc \ 96 mirror/array.cc \ 97 mirror/class.cc \ 98 mirror/dex_cache.cc \ 99 mirror/object.cc \ 100 mirror/stack_trace_element.cc \ 101 mirror/string.cc \ 102 mirror/throwable.cc \ 103 monitor.cc \ 104 native/dalvik_system_DexFile.cc \ 105 native/dalvik_system_VMDebug.cc \ 106 native/dalvik_system_VMRuntime.cc \ 107 native/dalvik_system_VMStack.cc \ 108 native/dalvik_system_ZygoteHooks.cc \ 109 native/java_lang_Class.cc \ 110 native/java_lang_DexCache.cc \ 111 native/java_lang_Object.cc \ 112 native/java_lang_Runtime.cc \ 113 native/java_lang_String.cc \ 114 native/java_lang_System.cc \ 115 native/java_lang_Thread.cc \ 116 native/java_lang_Throwable.cc \ 117 native/java_lang_VMClassLoader.cc \ 118 native/java_lang_ref_Reference.cc \ 119 native/java_lang_reflect_Array.cc \ 120 native/java_lang_reflect_Constructor.cc \ 121 native/java_lang_reflect_Field.cc \ 122 native/java_lang_reflect_Method.cc \ 123 native/java_lang_reflect_Proxy.cc \ 124 native/java_util_concurrent_atomic_AtomicLong.cc \ 125 native/org_apache_harmony_dalvik_ddmc_DdmServer.cc \ 126 native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc \ 127 native/sun_misc_Unsafe.cc \ 128 oat.cc \ 129 oat_file.cc \ 130 offsets.cc \ 131 os_linux.cc \ 132 parsed_options.cc \ 133 primitive.cc \ 134 quick_exception_handler.cc \ 135 quick/inline_method_analyser.cc \ 136 reference_table.cc \ 137 reflection.cc \ 138 runtime.cc \ 139 signal_catcher.cc \ 140 stack.cc \ 141 thread.cc \ 142 thread_list.cc \ 143 thread_pool.cc \ 144 throw_location.cc \ 145 trace.cc \ 146 transaction.cc \ 147 profiler.cc \ 148 fault_handler.cc \ 149 utf.cc \ 150 utils.cc \ 151 verifier/dex_gc_map.cc \ 152 verifier/instruction_flags.cc \ 153 verifier/method_verifier.cc \ 154 verifier/reg_type.cc \ 155 verifier/reg_type_cache.cc \ 156 verifier/register_line.cc \ 157 well_known_classes.cc \ 158 zip_archive.cc 159 160LIBART_COMMON_SRC_FILES += \ 161 arch/context.cc \ 162 arch/memcmp16.cc \ 163 arch/arm/registers_arm.cc \ 164 arch/arm64/registers_arm64.cc \ 165 arch/x86/registers_x86.cc \ 166 arch/mips/registers_mips.cc \ 167 entrypoints/entrypoint_utils.cc \ 168 entrypoints/interpreter/interpreter_entrypoints.cc \ 169 entrypoints/jni/jni_entrypoints.cc \ 170 entrypoints/math_entrypoints.cc \ 171 entrypoints/portable/portable_alloc_entrypoints.cc \ 172 entrypoints/portable/portable_cast_entrypoints.cc \ 173 entrypoints/portable/portable_dexcache_entrypoints.cc \ 174 entrypoints/portable/portable_field_entrypoints.cc \ 175 entrypoints/portable/portable_fillarray_entrypoints.cc \ 176 entrypoints/portable/portable_invoke_entrypoints.cc \ 177 entrypoints/portable/portable_jni_entrypoints.cc \ 178 entrypoints/portable/portable_lock_entrypoints.cc \ 179 entrypoints/portable/portable_thread_entrypoints.cc \ 180 entrypoints/portable/portable_throw_entrypoints.cc \ 181 entrypoints/portable/portable_trampoline_entrypoints.cc \ 182 entrypoints/quick/quick_alloc_entrypoints.cc \ 183 entrypoints/quick/quick_cast_entrypoints.cc \ 184 entrypoints/quick/quick_deoptimization_entrypoints.cc \ 185 entrypoints/quick/quick_dexcache_entrypoints.cc \ 186 entrypoints/quick/quick_field_entrypoints.cc \ 187 entrypoints/quick/quick_fillarray_entrypoints.cc \ 188 entrypoints/quick/quick_instrumentation_entrypoints.cc \ 189 entrypoints/quick/quick_jni_entrypoints.cc \ 190 entrypoints/quick/quick_lock_entrypoints.cc \ 191 entrypoints/quick/quick_math_entrypoints.cc \ 192 entrypoints/quick/quick_thread_entrypoints.cc \ 193 entrypoints/quick/quick_throw_entrypoints.cc \ 194 entrypoints/quick/quick_trampoline_entrypoints.cc 195 196# Source files that only compile with GCC. 197LIBART_GCC_ONLY_SRC_FILES := \ 198 interpreter/interpreter_goto_table_impl.cc 199 200LIBART_TARGET_LDFLAGS := 201LIBART_HOST_LDFLAGS := 202 203LIBART_TARGET_SRC_FILES := \ 204 $(LIBART_COMMON_SRC_FILES) \ 205 base/logging_android.cc \ 206 jdwp/jdwp_adb.cc \ 207 monitor_android.cc \ 208 runtime_android.cc \ 209 thread_android.cc 210 211LIBART_TARGET_SRC_FILES_arm := \ 212 arch/arm/context_arm.cc.arm \ 213 arch/arm/entrypoints_init_arm.cc \ 214 arch/arm/jni_entrypoints_arm.S \ 215 arch/arm/memcmp16_arm.S \ 216 arch/arm/portable_entrypoints_arm.S \ 217 arch/arm/quick_entrypoints_arm.S \ 218 arch/arm/arm_sdiv.S \ 219 arch/arm/thread_arm.cc \ 220 arch/arm/fault_handler_arm.cc 221 222LIBART_TARGET_SRC_FILES_arm64 := \ 223 arch/arm64/context_arm64.cc \ 224 arch/arm64/entrypoints_init_arm64.cc \ 225 arch/arm64/jni_entrypoints_arm64.S \ 226 arch/arm64/memcmp16_arm64.S \ 227 arch/arm64/portable_entrypoints_arm64.S \ 228 arch/arm64/quick_entrypoints_arm64.S \ 229 arch/arm64/thread_arm64.cc \ 230 monitor_pool.cc \ 231 arch/arm64/fault_handler_arm64.cc 232 233LIBART_SRC_FILES_x86 := \ 234 arch/x86/context_x86.cc \ 235 arch/x86/entrypoints_init_x86.cc \ 236 arch/x86/jni_entrypoints_x86.S \ 237 arch/x86/portable_entrypoints_x86.S \ 238 arch/x86/quick_entrypoints_x86.S \ 239 arch/x86/thread_x86.cc \ 240 arch/x86/fault_handler_x86.cc 241 242LIBART_TARGET_SRC_FILES_x86 := \ 243 $(LIBART_SRC_FILES_x86) 244 245LIBART_SRC_FILES_x86_64 := \ 246 arch/x86_64/context_x86_64.cc \ 247 arch/x86_64/entrypoints_init_x86_64.cc \ 248 arch/x86_64/jni_entrypoints_x86_64.S \ 249 arch/x86_64/portable_entrypoints_x86_64.S \ 250 arch/x86_64/quick_entrypoints_x86_64.S \ 251 arch/x86_64/thread_x86_64.cc \ 252 monitor_pool.cc \ 253 arch/x86_64/fault_handler_x86_64.cc 254 255LIBART_TARGET_SRC_FILES_x86_64 := \ 256 $(LIBART_SRC_FILES_x86_64) \ 257 258LIBART_TARGET_SRC_FILES_mips := \ 259 arch/mips/context_mips.cc \ 260 arch/mips/entrypoints_init_mips.cc \ 261 arch/mips/jni_entrypoints_mips.S \ 262 arch/mips/memcmp16_mips.S \ 263 arch/mips/portable_entrypoints_mips.S \ 264 arch/mips/quick_entrypoints_mips.S \ 265 arch/mips/thread_mips.cc \ 266 arch/mips/fault_handler_mips.cc 267 268ifeq ($(TARGET_ARCH),mips64) 269$(info TODOMips64: $(LOCAL_PATH)/Android.mk Add mips64 specific runtime files) 270endif # TARGET_ARCH != mips64 271 272LIBART_HOST_SRC_FILES := \ 273 $(LIBART_COMMON_SRC_FILES) \ 274 base/logging_linux.cc \ 275 monitor_linux.cc \ 276 runtime_linux.cc \ 277 thread_linux.cc 278 279LIBART_HOST_SRC_FILES_32 := \ 280 $(LIBART_SRC_FILES_x86) 281 282LIBART_HOST_SRC_FILES_64 := \ 283 $(LIBART_SRC_FILES_x86_64) 284 285LIBART_ENUM_OPERATOR_OUT_HEADER_FILES := \ 286 arch/x86_64/registers_x86_64.h \ 287 base/mutex.h \ 288 dex_file.h \ 289 dex_instruction.h \ 290 gc/collector/gc_type.h \ 291 gc/space/space.h \ 292 gc/heap.h \ 293 indirect_reference_table.h \ 294 instruction_set.h \ 295 invoke_type.h \ 296 jdwp/jdwp.h \ 297 jdwp/jdwp_constants.h \ 298 lock_word.h \ 299 mirror/class.h \ 300 oat.h \ 301 object_callbacks.h \ 302 quick/inline_method_analyser.h \ 303 thread.h \ 304 thread_state.h \ 305 verifier/method_verifier.h 306 307LIBART_CFLAGS := 308ifeq ($(ART_USE_PORTABLE_COMPILER),true) 309 LIBART_CFLAGS += -DART_USE_PORTABLE_COMPILER=1 310endif 311 312ifeq ($(MALLOC_IMPL),jemalloc) 313 LIBART_CFLAGS += -DUSE_JEMALLOC 314else 315 LIBART_CFLAGS += -DUSE_DLMALLOC 316endif 317 318# $(1): target or host 319# $(2): ndebug or debug 320define build-libart 321 ifneq ($(1),target) 322 ifneq ($(1),host) 323 $$(error expected target or host for argument 1, received $(1)) 324 endif 325 endif 326 ifneq ($(2),ndebug) 327 ifneq ($(2),debug) 328 $$(error expected ndebug or debug for argument 2, received $(2)) 329 endif 330 endif 331 332 art_target_or_host := $(1) 333 art_ndebug_or_debug := $(2) 334 335 include $$(CLEAR_VARS) 336 LOCAL_CPP_EXTENSION := $$(ART_CPP_EXTENSION) 337 ifeq ($$(art_ndebug_or_debug),ndebug) 338 LOCAL_MODULE := libart 339 else # debug 340 LOCAL_MODULE := libartd 341 endif 342 343 LOCAL_MODULE_TAGS := optional 344 LOCAL_MODULE_CLASS := SHARED_LIBRARIES 345 346 ifeq ($$(art_target_or_host),target) 347 LOCAL_SRC_FILES := $$(LIBART_TARGET_SRC_FILES) 348 $$(foreach arch,$$(ART_TARGET_SUPPORTED_ARCH), \ 349 $$(eval LOCAL_SRC_FILES_$$(arch) := $$$$(LIBART_TARGET_SRC_FILES_$$(arch)))) 350 else # host 351 LOCAL_SRC_FILES := $$(LIBART_HOST_SRC_FILES) 352 LOCAL_SRC_FILES_32 := $$(LIBART_HOST_SRC_FILES_32) 353 LOCAL_SRC_FILES_64 := $$(LIBART_HOST_SRC_FILES_64) 354 LOCAL_IS_HOST_MODULE := true 355 endif 356 357 GENERATED_SRC_DIR := $$(call local-generated-sources-dir) 358 ENUM_OPERATOR_OUT_CC_FILES := $$(patsubst %.h,%_operator_out.cc,$$(LIBART_ENUM_OPERATOR_OUT_HEADER_FILES)) 359 ENUM_OPERATOR_OUT_GEN := $$(addprefix $$(GENERATED_SRC_DIR)/,$$(ENUM_OPERATOR_OUT_CC_FILES)) 360 361$$(ENUM_OPERATOR_OUT_GEN): art/tools/generate-operator-out.py 362$$(ENUM_OPERATOR_OUT_GEN): PRIVATE_CUSTOM_TOOL = art/tools/generate-operator-out.py $(LOCAL_PATH) $$< > $$@ 363$$(ENUM_OPERATOR_OUT_GEN): $$(GENERATED_SRC_DIR)/%_operator_out.cc : $(LOCAL_PATH)/%.h 364 $$(transform-generated-source) 365 366 LOCAL_GENERATED_SOURCES += $$(ENUM_OPERATOR_OUT_GEN) 367 368 LOCAL_CFLAGS := $$(LIBART_CFLAGS) 369 LOCAL_LDFLAGS := $$(LIBART_LDFLAGS) 370 ifeq ($$(art_target_or_host),target) 371 LOCAL_LDFLAGS += $$(LIBART_TARGET_LDFLAGS) 372 else 373 LOCAL_LDFLAGS += $$(LIBART_HOST_LDFLAGS) 374 endif 375 $$(foreach arch,$$(ART_TARGET_SUPPORTED_ARCH), \ 376 $$(eval LOCAL_LDFLAGS_$$(arch) := $$(LIBART_TARGET_LDFLAGS_$$(arch)))) 377 378 # Clang usage 379 ifeq ($$(art_target_or_host),target) 380 $$(eval $$(call set-target-local-clang-vars)) 381 $$(eval $$(call set-target-local-cflags-vars,$(2))) 382 # TODO: Loop with ifeq, ART_TARGET_CLANG 383 ifneq ($$(ART_TARGET_CLANG_$$(TARGET_ARCH)),true) 384 LOCAL_SRC_FILES_$$(TARGET_ARCH) += $$(LIBART_GCC_ONLY_SRC_FILES) 385 endif 386 ifneq ($$(ART_TARGET_CLANG_$$(TARGET_2ND_ARCH)),true) 387 LOCAL_SRC_FILES_$$(TARGET_2ND_ARCH) += $$(LIBART_GCC_ONLY_SRC_FILES) 388 endif 389 else # host 390 LOCAL_CLANG := $$(ART_HOST_CLANG) 391 ifeq ($$(ART_HOST_CLANG),false) 392 LOCAL_SRC_FILES += $$(LIBART_GCC_ONLY_SRC_FILES) 393 endif 394 LOCAL_CFLAGS += $$(ART_HOST_CFLAGS) 395 ifeq ($$(art_ndebug_or_debug),debug) 396 LOCAL_CFLAGS += $$(ART_HOST_DEBUG_CFLAGS) 397 LOCAL_LDLIBS += $$(ART_HOST_DEBUG_LDLIBS) 398 LOCAL_STATIC_LIBRARIES := libgtest_host 399 else 400 LOCAL_CFLAGS += $$(ART_HOST_NON_DEBUG_CFLAGS) 401 endif 402 endif 403 404 LOCAL_C_INCLUDES += $$(ART_C_INCLUDES) 405 LOCAL_C_INCLUDES += art/sigchainlib 406 407 LOCAL_SHARED_LIBRARIES += liblog libnativehelper 408 include external/libcxx/libcxx.mk 409 LOCAL_SHARED_LIBRARIES += libbacktrace_libc++ 410 ifeq ($$(art_target_or_host),target) 411 LOCAL_SHARED_LIBRARIES += libcutils libdl libselinux libutils libsigchain 412 LOCAL_STATIC_LIBRARIES := libziparchive libz 413 else # host 414 LOCAL_STATIC_LIBRARIES += libcutils libziparchive-host libz libutils 415 LOCAL_LDLIBS += -ldl -lpthread 416 ifeq ($$(HOST_OS),linux) 417 LOCAL_LDLIBS += -lrt 418 endif 419 LOCAL_MULTILIB := both 420 endif 421 ifeq ($$(ART_USE_PORTABLE_COMPILER),true) 422 include $$(LLVM_GEN_INTRINSICS_MK) 423 ifeq ($$(art_target_or_host),target) 424 include $$(LLVM_DEVICE_BUILD_MK) 425 else # host 426 include $$(LLVM_HOST_BUILD_MK) 427 endif 428 endif 429 LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_build.mk 430# LOCAL_ADDITIONAL_DEPENDENCIES += $$(LOCAL_PATH)/Android.mk 431 432 ifeq ($$(art_target_or_host),target) 433 LOCAL_MODULE_TARGET_ARCH := $$(ART_TARGET_SUPPORTED_ARCH) 434 endif 435 436 ifeq ($$(art_target_or_host),target) 437 ifneq ($$(art_ndebug_or_debug),debug) 438 # Leave the symbols in the shared library so that stack unwinders can 439 # produce meaningful name resolution. 440 LOCAL_STRIP_MODULE := keep_symbols 441 endif 442 include $$(BUILD_SHARED_LIBRARY) 443 else # host 444 include $$(BUILD_HOST_SHARED_LIBRARY) 445 endif 446 447 # Clear locally defined variables. 448 GENERATED_SRC_DIR := 449 ENUM_OPERATOR_OUT_CC_FILES := 450 ENUM_OPERATOR_OUT_GEN := 451 art_target_or_host := 452 art_ndebug_or_debug := 453endef 454 455# We always build dex2oat and dependencies, even if the host build is otherwise disabled, since 456# they are used to cross compile for the target. 457ifeq ($(ART_BUILD_NDEBUG),true) 458 $(eval $(call build-libart,host,ndebug)) 459endif 460ifeq ($(ART_BUILD_DEBUG),true) 461 $(eval $(call build-libart,host,debug)) 462endif 463 464ifeq ($(ART_BUILD_TARGET_NDEBUG),true) 465# $(error $(call build-libart,target,ndebug)) 466 $(eval $(call build-libart,target,ndebug)) 467endif 468ifeq ($(ART_BUILD_TARGET_DEBUG),true) 469 $(eval $(call build-libart,target,debug)) 470endif 471 472# Clear locally defined variables. 473LOCAL_PATH := 474LIBART_COMMON_SRC_FILES := 475LIBART_GCC_ONLY_SRC_FILES := 476LIBART_TARGET_LDFLAGS := 477LIBART_HOST_LDFLAGS := 478LIBART_TARGET_SRC_FILES := 479LIBART_TARGET_SRC_FILES_arm := 480LIBART_TARGET_SRC_FILES_arm64 := 481LIBART_TARGET_SRC_FILES_x86 := 482LIBART_TARGET_SRC_FILES_x86_64 := 483LIBART_TARGET_SRC_FILES_mips := 484LIBART_HOST_SRC_FILES := 485LIBART_HOST_SRC_FILES_32 := 486LIBART_HOST_SRC_FILES_64 := 487LIBART_ENUM_OPERATOR_OUT_HEADER_FILES := 488LIBART_CFLAGS := 489build-libart := 490