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)$(LOCAL_MODULE_STEM_32)$(LOCAL_MODULE_STEM_64)),) 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_SYSTEM)/prebuilt_internal.mk 29skip_build_from_source := true 30endif 31endif 32 33ifndef skip_build_from_source 34 35# Put the built targets of all shared libraries in a common directory 36# to simplify the link line. 37OVERRIDE_BUILT_MODULE_PATH := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES) 38 39include $(BUILD_SYSTEM)/dynamic_binary.mk 40 41# Define PRIVATE_ variables from global vars 42my_target_global_ld_dirs := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LD_DIRS) 43my_target_libgcc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCC) 44my_target_libatomic := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBATOMIC) 45my_target_crtbegin_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_CRTBEGIN_SO_O) 46my_target_crtend_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_CRTEND_SO_O) 47ifdef LOCAL_SDK_VERSION 48# Make sure the prebuilt NDK paths are put ahead of the TARGET_GLOBAL_LD_DIRS, 49# so we don't have race condition when the system libraries (such as libc, libstdc++) are also built in the tree. 50my_target_global_ld_dirs := \ 51 $(addprefix -L, $(patsubst %/,%,$(dir $(my_ndk_stl_shared_lib_fullpath))) \ 52 $(my_ndk_sysroot_lib)) \ 53 $(my_target_global_ld_dirs) 54my_target_global_ldflags := $(my_ndk_stl_shared_lib) $(my_target_global_ldflags) 55my_target_crtbegin_so_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_so.o) 56my_target_crtend_so_o := $(wildcard $(my_ndk_sysroot_lib)/crtend_so.o) 57endif 58$(linked_module): PRIVATE_TARGET_GLOBAL_LD_DIRS := $(my_target_global_ld_dirs) 59$(linked_module): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags) 60$(linked_module): PRIVATE_TARGET_LIBGCC := $(my_target_libgcc) 61$(linked_module): PRIVATE_TARGET_LIBATOMIC := $(my_target_libatomic) 62$(linked_module): PRIVATE_TARGET_CRTBEGIN_SO_O := $(my_target_crtbegin_so_o) 63$(linked_module): PRIVATE_TARGET_CRTEND_SO_O := $(my_target_crtend_so_o) 64 65$(linked_module): $(all_objects) $(all_libraries) \ 66 $(LOCAL_ADDITIONAL_DEPENDENCIES) \ 67 $(my_target_crtbegin_so_o) $(my_target_crtend_so_o) 68 $(transform-o-to-shared-lib) 69 70endif # skip_build_from_source 71