shared_library.mk revision e6f65438a45f0e1b519fb3cd2799f44ca87911a7
1########################################################### 2## Standard rules for building a normal shared library. 3## 4## Additional inputs from base_rules.make: 5## None. 6## 7## LOCAL_MODULE_SUFFIX will be set for you. 8########################################################### 9 10ifeq ($(strip $(LOCAL_MODULE_CLASS)),) 11LOCAL_MODULE_CLASS := SHARED_LIBRARIES 12endif 13ifeq ($(strip $(LOCAL_MODULE_SUFFIX)),) 14LOCAL_MODULE_SUFFIX := $(TARGET_SHLIB_SUFFIX) 15endif 16ifneq ($(strip $(OVERRIDE_BUILT_MODULE_PATH)),) 17$(error $(LOCAL_PATH): Illegal use of OVERRIDE_BUILT_MODULE_PATH) 18endif 19ifneq ($(strip $(LOCAL_MODULE_STEM)$(LOCAL_BUILT_MODULE_STEM)),) 20$(error $(LOCAL_PATH): Cannot set module stem for a library) 21endif 22 23$(call target-shared-library-hook) 24 25skip_build_from_source := 26ifdef LOCAL_PREBUILT_MODULE_FILE 27ifeq (,$(call if-build-from-source,$(LOCAL_MODULE),$(LOCAL_PATH))) 28include $(BUILD_PREBUILT) 29skip_build_from_source := true 30endif 31endif 32 33ifndef skip_build_from_source 34#################################################### 35## Add profiling libraries if aprof is turned 36#################################################### 37ifeq ($(strip $(LOCAL_ENABLE_APROF_JNI)),true) 38 LOCAL_ENABLE_APROF := true 39 LOCAL_WHOLE_STATIC_LIBRARIES += libaprof_jni 40endif 41 42ifeq ($(strip $(LOCAL_ENABLE_APROF)),true) 43 LOCAL_SHARED_LIBRARIES += libaprof libaprof_runtime 44endif 45 46# Put the built targets of all shared libraries in a common directory 47# to simplify the link line. 48OVERRIDE_BUILT_MODULE_PATH := $(TARGET_OUT_INTERMEDIATE_LIBRARIES) 49 50include $(BUILD_SYSTEM)/dynamic_binary.mk 51 52 53# Define PRIVATE_ variables from global vars 54my_target_global_ld_dirs := $(TARGET_GLOBAL_LD_DIRS) 55ifeq ($(LOCAL_CLANG),true) 56my_target_global_ldflags := $(CLANG_TARGET_GLOBAL_LDFLAGS) 57else 58my_target_global_ldflags := $(TARGET_GLOBAL_LDFLAGS) 59endif 60my_target_fdo_lib := $(TARGET_FDO_LIB) 61my_target_libgcc := $(TARGET_LIBGCC) 62my_target_crtbegin_so_o := $(TARGET_CRTBEGIN_SO_O) 63my_target_crtend_so_o := $(TARGET_CRTEND_SO_O) 64ifdef LOCAL_SDK_VERSION 65# Make sure the prebuilt NDK paths are put ahead of the TARGET_GLOBAL_LD_DIRS, 66# so we don't have race condition when the system libraries (such as libc, libstdc++) are also built in the tree. 67my_target_global_ld_dirs := \ 68 $(addprefix -L, $(patsubst %/,%,$(dir $(my_ndk_stl_shared_lib_fullpath))) \ 69 $(my_ndk_version_root)/usr/lib) \ 70 $(my_target_global_ld_dirs) 71my_target_global_ldflags := $(my_ndk_stl_shared_lib) $(my_target_global_ldflags) 72my_target_crtbegin_so_o := $(wildcard $(my_ndk_version_root)/usr/lib/crtbegin_so.o) 73my_target_crtend_so_o := $(wildcard $(my_ndk_version_root)/usr/lib/crtend_so.o) 74endif 75$(linked_module): PRIVATE_TARGET_GLOBAL_LD_DIRS := $(my_target_global_ld_dirs) 76$(linked_module): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags) 77$(linked_module): PRIVATE_TARGET_FDO_LIB := $(my_target_fdo_lib) 78$(linked_module): PRIVATE_TARGET_LIBGCC := $(my_target_libgcc) 79$(linked_module): PRIVATE_TARGET_CRTBEGIN_SO_O := $(my_target_crtbegin_so_o) 80$(linked_module): PRIVATE_TARGET_CRTEND_SO_O := $(my_target_crtend_so_o) 81 82$(linked_module): $(all_objects) $(all_libraries) \ 83 $(LOCAL_ADDITIONAL_DEPENDENCIES) \ 84 $(my_target_crtbegin_so_o) $(my_target_crtend_so_o) 85 $(transform-o-to-shared-lib) 86 87endif # skip_build_from_source 88