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 $(LOCAL_MODULE_STEM)$(LOCAL_BUILT_MODULE_STEM)$(LOCAL_MODULE_STEM_32)$(LOCAL_MODULE_STEM_64)),) 17$(error $(LOCAL_PATH): Cannot set module stem for a library) 18endif 19 20ifdef target-shared-library-hook 21$(call target-shared-library-hook) 22endif 23 24skip_build_from_source := 25ifdef LOCAL_PREBUILT_MODULE_FILE 26ifeq (,$(call if-build-from-source,$(LOCAL_MODULE),$(LOCAL_PATH))) 27include $(BUILD_SYSTEM)/prebuilt_internal.mk 28skip_build_from_source := true 29endif 30endif 31 32ifndef skip_build_from_source 33 34include $(BUILD_SYSTEM)/dynamic_binary.mk 35 36# Define PRIVATE_ variables from global vars 37ifeq ($(LOCAL_NO_LIBCRT_BUILTINS),true) 38my_target_libcrt_builtins := 39else 40my_target_libcrt_builtins := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBCRT_BUILTINS) 41endif 42my_target_libatomic := $(call intermediates-dir-for,STATIC_LIBRARIES,libatomic,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libatomic.a 43ifeq ($(LOCAL_NO_CRT),true) 44my_target_crtbegin_so_o := 45my_target_crtend_so_o := 46else ifdef LOCAL_USE_VNDK 47my_target_crtbegin_so_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtbegin_so.vendor) 48my_target_crtend_so_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtend_so.vendor) 49else 50my_target_crtbegin_so_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtbegin_so) 51my_target_crtend_so_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtend_so) 52endif 53ifneq ($(LOCAL_SDK_VERSION),) 54my_target_crtbegin_so_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_so.o) 55my_target_crtend_so_o := $(wildcard $(my_ndk_sysroot_lib)/crtend_so.o) 56endif 57$(linked_module): PRIVATE_TARGET_LIBCRT_BUILTINS := $(my_target_libcrt_builtins) 58$(linked_module): PRIVATE_TARGET_LIBATOMIC := $(my_target_libatomic) 59$(linked_module): PRIVATE_TARGET_CRTBEGIN_SO_O := $(my_target_crtbegin_so_o) 60$(linked_module): PRIVATE_TARGET_CRTEND_SO_O := $(my_target_crtend_so_o) 61 62$(linked_module): \ 63 $(all_objects) \ 64 $(all_libraries) \ 65 $(my_target_crtbegin_so_o) \ 66 $(my_target_crtend_so_o) \ 67 $(my_target_libcrt_builtins) \ 68 $(my_target_libatomic) \ 69 $(LOCAL_ADDITIONAL_DEPENDENCIES) $(CLANG_CXX) 70 $(transform-o-to-shared-lib) 71 72ifeq ($(my_native_coverage),true) 73gcno_suffix := .zip 74 75built_whole_gcno_libraries := \ 76 $(foreach lib,$(my_whole_static_libraries), \ 77 $(call intermediates-dir-for, \ 78 STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX), \ 79 $(my_host_cross))/$(lib)$(gcno_suffix)) 80 81built_static_gcno_libraries := \ 82 $(foreach lib,$(my_static_libraries), \ 83 $(call intermediates-dir-for, \ 84 STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX), \ 85 $(my_host_cross))/$(lib)$(gcno_suffix)) 86 87ifdef LOCAL_IS_HOST_MODULE 88my_coverage_path := $($(my_prefix)OUT_COVERAGE)/$(patsubst $($(my_prefix)OUT)/%,%,$(my_module_path)) 89else 90my_coverage_path := $(TARGET_OUT_COVERAGE)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path)) 91endif 92 93GCNO_ARCHIVE := $(basename $(my_installed_module_stem))$(gcno_suffix) 94 95$(intermediates)/$(GCNO_ARCHIVE) : $(SOONG_ZIP) $(MERGE_ZIPS) 96$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_OBJECTS := $(strip $(LOCAL_GCNO_FILES)) 97$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(strip $(built_whole_gcno_libraries)) $(strip $(built_static_gcno_libraries)) 98$(intermediates)/$(GCNO_ARCHIVE) : $(LOCAL_GCNO_FILES) $(built_whole_gcno_libraries) $(built_static_gcno_libraries) 99 $(package-coverage-files) 100 101$(my_coverage_path)/$(GCNO_ARCHIVE) : $(intermediates)/$(GCNO_ARCHIVE) 102 $(copy-file-to-target) 103 104$(LOCAL_BUILT_MODULE): $(my_coverage_path)/$(GCNO_ARCHIVE) 105endif 106 107endif # skip_build_from_source 108