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 10 ifeq ($(strip $(LOCAL_MODULE_CLASS)),) 11 LOCAL_MODULE_CLASS := SHARED_LIBRARIES 12 endif 13 ifeq ($(strip $(LOCAL_MODULE_SUFFIX)),) 14 LOCAL_MODULE_SUFFIX := $(TARGET_SHLIB_SUFFIX) 15 endif 16 ifneq ($(strip $(OVERRIDE_BUILT_MODULE_PATH)),) 17 $(error $(LOCAL_PATH): Illegal use of OVERRIDE_BUILT_MODULE_PATH) 18 endif 19 ifneq ($(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) 21 endif 22 23 ifdef target-shared-library-hook 24 $(call target-shared-library-hook) 25 endif 26 27 skip_build_from_source := 28 ifdef LOCAL_PREBUILT_MODULE_FILE 29 ifeq (,$(call if-build-from-source,$(LOCAL_MODULE),$(LOCAL_PATH))) 30 include $(BUILD_SYSTEM)/prebuilt_internal.mk 31 skip_build_from_source := true 32 endif 33 endif 34 35 ifndef skip_build_from_source 36 37 # Put the built targets of all shared libraries in a common directory 38 # to simplify the link line. 39 OVERRIDE_BUILT_MODULE_PATH := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES) 40 41 include $(BUILD_SYSTEM)/dynamic_binary.mk 42 43 # Define PRIVATE_ variables from global vars 44 ifeq ($(LOCAL_NO_LIBGCC),true) 45 my_target_libgcc := 46 else 47 my_target_libgcc := $(call intermediates-dir-for,STATIC_LIBRARIES,libgcc,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libgcc.a 48 endif 49 my_target_libatomic := $(call intermediates-dir-for,STATIC_LIBRARIES,libatomic,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libatomic.a 50 ifeq ($(LOCAL_NO_CRT),true) 51 my_target_crtbegin_so_o := 52 my_target_crtend_so_o := 53 else ifdef LOCAL_USE_VNDK 54 my_target_crtbegin_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.vendor.o 55 my_target_crtend_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.vendor.o 56 else 57 my_target_crtbegin_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o 58 my_target_crtend_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o 59 endif 60 ifneq ($(LOCAL_SDK_VERSION),) 61 my_target_crtbegin_so_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_so.o) 62 my_target_crtend_so_o := $(wildcard $(my_ndk_sysroot_lib)/crtend_so.o) 63 endif 64 $(linked_module): PRIVATE_TARGET_LIBGCC := $(my_target_libgcc) 65 $(linked_module): PRIVATE_TARGET_LIBATOMIC := $(my_target_libatomic) 66 $(linked_module): PRIVATE_TARGET_CRTBEGIN_SO_O := $(my_target_crtbegin_so_o) 67 $(linked_module): PRIVATE_TARGET_CRTEND_SO_O := $(my_target_crtend_so_o) 68 69 $(linked_module): \ 70 $(all_objects) \ 71 $(all_libraries) \ 72 $(my_target_crtbegin_so_o) \ 73 $(my_target_crtend_so_o) \ 74 $(my_target_libgcc) \ 75 $(my_target_libatomic) \ 76 $(LOCAL_ADDITIONAL_DEPENDENCIES) 77 $(transform-o-to-shared-lib) 78 79 ifeq ($(my_native_coverage),true) 80 gcno_suffix := .gcnodir 81 82 built_whole_gcno_libraries := \ 83 $(foreach lib,$(my_whole_static_libraries), \ 84 $(call intermediates-dir-for, \ 85 STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX), \ 86 $(my_host_cross))/$(lib)$(gcno_suffix)) 87 88 built_static_gcno_libraries := \ 89 $(foreach lib,$(my_static_libraries), \ 90 $(call intermediates-dir-for, \ 91 STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX), \ 92 $(my_host_cross))/$(lib)$(gcno_suffix)) 93 94 ifdef LOCAL_IS_HOST_MODULE 95 my_coverage_path := $($(my_prefix)OUT_COVERAGE)/$(patsubst $($(my_prefix)OUT)/%,%,$(my_module_path)) 96 else 97 my_coverage_path := $(TARGET_OUT_COVERAGE)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path)) 98 endif 99 100 GCNO_ARCHIVE := $(basename $(my_installed_module_stem))$(gcno_suffix) 101 102 $(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_OBJECTS := $(strip $(LOCAL_GCNO_FILES)) 103 $(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(strip $(built_whole_gcno_libraries)) $(strip $(built_static_gcno_libraries)) 104 $(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_INTERMEDIATES_DIR := $(intermediates) 105 $(intermediates)/$(GCNO_ARCHIVE) : $(LOCAL_GCNO_FILES) $(built_whole_gcno_libraries) $(built_static_gcno_libraries) 106 $(transform-o-to-static-lib) 107 108 $(my_coverage_path)/$(GCNO_ARCHIVE) : $(intermediates)/$(GCNO_ARCHIVE) 109 $(copy-file-to-target) 110 111 $(LOCAL_BUILT_MODULE): $(my_coverage_path)/$(GCNO_ARCHIVE) 112 endif 113 114 endif # skip_build_from_source 115