• 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 $(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
42ifeq ($(LOCAL_NO_LIBGCC),true)
43my_target_libgcc :=
44else
45my_target_libgcc := $(call intermediates-dir-for,STATIC_LIBRARIES,libgcc,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libgcc.a
46endif
47my_target_libatomic := $(call intermediates-dir-for,STATIC_LIBRARIES,libatomic,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libatomic.a
48ifeq ($(LOCAL_NO_CRT),true)
49my_target_crtbegin_so_o :=
50my_target_crtend_so_o :=
51else ifdef LOCAL_USE_VNDK
52my_target_crtbegin_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.vendor.o
53my_target_crtend_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.vendor.o
54else
55my_target_crtbegin_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
56my_target_crtend_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
57endif
58ifneq ($(LOCAL_SDK_VERSION),)
59my_target_crtbegin_so_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_so.o)
60my_target_crtend_so_o := $(wildcard $(my_ndk_sysroot_lib)/crtend_so.o)
61endif
62$(linked_module): PRIVATE_TARGET_LIBGCC := $(my_target_libgcc)
63$(linked_module): PRIVATE_TARGET_LIBATOMIC := $(my_target_libatomic)
64$(linked_module): PRIVATE_TARGET_CRTBEGIN_SO_O := $(my_target_crtbegin_so_o)
65$(linked_module): PRIVATE_TARGET_CRTEND_SO_O := $(my_target_crtend_so_o)
66
67$(linked_module): \
68        $(all_objects) \
69        $(all_libraries) \
70        $(my_target_crtbegin_so_o) \
71        $(my_target_crtend_so_o) \
72        $(my_target_libgcc) \
73        $(my_target_libatomic) \
74        $(LOCAL_ADDITIONAL_DEPENDENCIES)
75	$(transform-o-to-shared-lib)
76
77ifeq ($(my_native_coverage),true)
78gcno_suffix := .gcnodir
79
80built_whole_gcno_libraries := \
81    $(foreach lib,$(my_whole_static_libraries), \
82      $(call intermediates-dir-for, \
83        STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX), \
84        $(my_host_cross))/$(lib)$(gcno_suffix))
85
86built_static_gcno_libraries := \
87    $(foreach lib,$(my_static_libraries), \
88      $(call intermediates-dir-for, \
89        STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX), \
90        $(my_host_cross))/$(lib)$(gcno_suffix))
91
92ifdef LOCAL_IS_HOST_MODULE
93my_coverage_path := $($(my_prefix)OUT_COVERAGE)/$(patsubst $($(my_prefix)OUT)/%,%,$(my_module_path))
94else
95my_coverage_path := $(TARGET_OUT_COVERAGE)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path))
96endif
97
98GCNO_ARCHIVE := $(basename $(my_installed_module_stem))$(gcno_suffix)
99
100$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_OBJECTS := $(strip $(LOCAL_GCNO_FILES))
101$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(strip $(built_whole_gcno_libraries)) $(strip $(built_static_gcno_libraries))
102$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_INTERMEDIATES_DIR := $(intermediates)
103$(intermediates)/$(GCNO_ARCHIVE) : $(LOCAL_GCNO_FILES) $(built_whole_gcno_libraries) $(built_static_gcno_libraries)
104	$(transform-o-to-static-lib)
105
106$(my_coverage_path)/$(GCNO_ARCHIVE) : $(intermediates)/$(GCNO_ARCHIVE)
107	$(copy-file-to-target)
108
109$(LOCAL_BUILT_MODULE): $(my_coverage_path)/$(GCNO_ARCHIVE)
110endif
111
112endif  # skip_build_from_source
113