• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
42ifeq ($(LOCAL_NO_CRT),true)
43my_target_crtbegin_so_o :=
44my_target_crtend_so_o :=
45else ifdef LOCAL_USE_VNDK
46my_target_crtbegin_so_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtbegin_so.vendor)
47my_target_crtend_so_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtend_so.vendor)
48else
49my_target_crtbegin_so_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtbegin_so)
50my_target_crtend_so_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtend_so)
51endif
52ifneq ($(LOCAL_SDK_VERSION),)
53my_target_crtbegin_so_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtbegin_so.sdk.$(my_ndk_crt_version))
54my_target_crtend_so_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtend_so.sdk.$(my_ndk_crt_version))
55endif
56$(linked_module): PRIVATE_TARGET_LIBCRT_BUILTINS := $(my_target_libcrt_builtins)
57$(linked_module): PRIVATE_TARGET_CRTBEGIN_SO_O := $(my_target_crtbegin_so_o)
58$(linked_module): PRIVATE_TARGET_CRTEND_SO_O := $(my_target_crtend_so_o)
59
60$(linked_module): \
61        $(all_objects) \
62        $(all_libraries) \
63        $(my_target_crtbegin_so_o) \
64        $(my_target_crtend_so_o) \
65        $(my_target_libcrt_builtins) \
66        $(LOCAL_ADDITIONAL_DEPENDENCIES) $(CLANG_CXX)
67	$(transform-o-to-shared-lib)
68
69ifeq ($(my_native_coverage),true)
70gcno_suffix := .zip
71
72built_whole_gcno_libraries := \
73    $(foreach lib,$(my_whole_static_libraries), \
74      $(call intermediates-dir-for, \
75        STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX), \
76        $(my_host_cross))/$(lib)$(gcno_suffix))
77
78built_static_gcno_libraries := \
79    $(foreach lib,$(my_static_libraries), \
80      $(call intermediates-dir-for, \
81        STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX), \
82        $(my_host_cross))/$(lib)$(gcno_suffix))
83
84ifdef LOCAL_IS_HOST_MODULE
85my_coverage_path := $($(my_prefix)OUT_COVERAGE)/$(patsubst $($(my_prefix)OUT)/%,%,$(my_module_path))
86else
87my_coverage_path := $(TARGET_OUT_COVERAGE)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path))
88endif
89
90GCNO_ARCHIVE := $(basename $(my_installed_module_stem))$(gcno_suffix)
91
92$(intermediates)/$(GCNO_ARCHIVE) : $(SOONG_ZIP) $(MERGE_ZIPS)
93$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_OBJECTS := $(strip $(LOCAL_GCNO_FILES))
94$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(strip $(built_whole_gcno_libraries)) $(strip $(built_static_gcno_libraries))
95$(intermediates)/$(GCNO_ARCHIVE) : $(LOCAL_GCNO_FILES) $(built_whole_gcno_libraries) $(built_static_gcno_libraries)
96	$(package-coverage-files)
97
98$(my_coverage_path)/$(GCNO_ARCHIVE) : $(intermediates)/$(GCNO_ARCHIVE)
99	$(copy-file-to-target)
100
101$(LOCAL_BUILT_MODULE): $(my_coverage_path)/$(GCNO_ARCHIVE)
102endif
103
104endif  # skip_build_from_source
105