Ying Wang | 4d2cc66 | 2014-01-16 12:36:34 -0800 | [diff] [blame] | 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 |
Colin Cross | 5a9db90 | 2014-03-21 12:27:37 -0700 | [diff] [blame] | 19 | ifneq ($(strip $(LOCAL_MODULE_STEM)$(LOCAL_BUILT_MODULE_STEM)$(LOCAL_MODULE_STEM_32)$(LOCAL_MODULE_STEM_64)),) |
Ying Wang | 4d2cc66 | 2014-01-16 12:36:34 -0800 | [diff] [blame] | 20 | $(error $(LOCAL_PATH): Cannot set module stem for a library) |
| 21 | endif |
| 22 | |
| 23 | $(call target-shared-library-hook) |
| 24 | |
| 25 | skip_build_from_source := |
| 26 | ifdef LOCAL_PREBUILT_MODULE_FILE |
| 27 | ifeq (,$(call if-build-from-source,$(LOCAL_MODULE),$(LOCAL_PATH))) |
Ying Wang | 58f462f | 2014-02-25 18:26:29 -0800 | [diff] [blame] | 28 | include $(BUILD_SYSTEM)/prebuilt_internal.mk |
Ying Wang | 4d2cc66 | 2014-01-16 12:36:34 -0800 | [diff] [blame] | 29 | skip_build_from_source := true |
| 30 | endif |
| 31 | endif |
| 32 | |
| 33 | ifndef skip_build_from_source |
| 34 | |
| 35 | # Put the built targets of all shared libraries in a common directory |
| 36 | # to simplify the link line. |
| 37 | OVERRIDE_BUILT_MODULE_PATH := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES) |
| 38 | |
| 39 | include $(BUILD_SYSTEM)/dynamic_binary.mk |
| 40 | |
| 41 | # Define PRIVATE_ variables from global vars |
| 42 | my_target_global_ld_dirs := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LD_DIRS) |
Ying Wang | 75011b2 | 2015-07-02 11:05:27 -0700 | [diff] [blame] | 43 | ifeq ($(LOCAL_NO_LIBGCC),true) |
| 44 | my_target_libgcc := |
| 45 | else |
Dan Willemsen | db16dd2 | 2016-05-16 14:41:49 -0700 | [diff] [blame] | 46 | my_target_libgcc := $(call intermediates-dir-for,STATIC_LIBRARIES,libgcc,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libgcc.a |
Ying Wang | 75011b2 | 2015-07-02 11:05:27 -0700 | [diff] [blame] | 47 | endif |
Dan Willemsen | db16dd2 | 2016-05-16 14:41:49 -0700 | [diff] [blame] | 48 | my_target_libatomic := $(call intermediates-dir-for,STATIC_LIBRARIES,libatomic,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libatomic.a |
Ying Wang | 491fca9 | 2015-07-02 15:57:45 -0700 | [diff] [blame] | 49 | ifeq ($(LOCAL_NO_CRT),true) |
| 50 | my_target_crtbegin_so_o := |
| 51 | my_target_crtend_so_o := |
| 52 | else |
Dan Willemsen | 056609c | 2016-05-16 22:07:31 -0700 | [diff] [blame^] | 53 | my_target_crtbegin_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o |
| 54 | my_target_crtend_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o |
Ying Wang | 491fca9 | 2015-07-02 15:57:45 -0700 | [diff] [blame] | 55 | endif |
Ying Wang | 4d2cc66 | 2014-01-16 12:36:34 -0800 | [diff] [blame] | 56 | ifdef LOCAL_SDK_VERSION |
| 57 | # Make sure the prebuilt NDK paths are put ahead of the TARGET_GLOBAL_LD_DIRS, |
| 58 | # so we don't have race condition when the system libraries (such as libc, libstdc++) are also built in the tree. |
| 59 | my_target_global_ld_dirs := \ |
| 60 | $(addprefix -L, $(patsubst %/,%,$(dir $(my_ndk_stl_shared_lib_fullpath))) \ |
Andrew Hsieh | 140761af0 | 2014-04-25 23:47:10 -0700 | [diff] [blame] | 61 | $(my_ndk_sysroot_lib)) \ |
Ying Wang | 4d2cc66 | 2014-01-16 12:36:34 -0800 | [diff] [blame] | 62 | $(my_target_global_ld_dirs) |
| 63 | my_target_global_ldflags := $(my_ndk_stl_shared_lib) $(my_target_global_ldflags) |
Andrew Hsieh | 140761af0 | 2014-04-25 23:47:10 -0700 | [diff] [blame] | 64 | my_target_crtbegin_so_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_so.o) |
| 65 | my_target_crtend_so_o := $(wildcard $(my_ndk_sysroot_lib)/crtend_so.o) |
Ying Wang | 4d2cc66 | 2014-01-16 12:36:34 -0800 | [diff] [blame] | 66 | endif |
| 67 | $(linked_module): PRIVATE_TARGET_GLOBAL_LD_DIRS := $(my_target_global_ld_dirs) |
| 68 | $(linked_module): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags) |
Ying Wang | 4d2cc66 | 2014-01-16 12:36:34 -0800 | [diff] [blame] | 69 | $(linked_module): PRIVATE_TARGET_LIBGCC := $(my_target_libgcc) |
Andrew Hsieh | 4c952d7 | 2014-05-29 02:47:27 -0700 | [diff] [blame] | 70 | $(linked_module): PRIVATE_TARGET_LIBATOMIC := $(my_target_libatomic) |
Ying Wang | 4d2cc66 | 2014-01-16 12:36:34 -0800 | [diff] [blame] | 71 | $(linked_module): PRIVATE_TARGET_CRTBEGIN_SO_O := $(my_target_crtbegin_so_o) |
| 72 | $(linked_module): PRIVATE_TARGET_CRTEND_SO_O := $(my_target_crtend_so_o) |
| 73 | |
Dan Albert | 954b5bd | 2014-11-08 22:20:03 -0800 | [diff] [blame] | 74 | $(linked_module): \ |
| 75 | $(all_objects) \ |
| 76 | $(all_libraries) \ |
| 77 | $(my_target_crtbegin_so_o) \ |
| 78 | $(my_target_crtend_so_o) \ |
Dan Willemsen | db16dd2 | 2016-05-16 14:41:49 -0700 | [diff] [blame] | 79 | $(my_target_libgcc) \ |
| 80 | $(my_target_libatomic) \ |
Dan Albert | 954b5bd | 2014-11-08 22:20:03 -0800 | [diff] [blame] | 81 | $(LOCAL_ADDITIONAL_DEPENDENCIES) |
Ying Wang | 4d2cc66 | 2014-01-16 12:36:34 -0800 | [diff] [blame] | 82 | $(transform-o-to-shared-lib) |
| 83 | |
| 84 | endif # skip_build_from_source |