The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -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 |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 16 | ifneq ($(strip $(OVERRIDE_BUILT_MODULE_PATH)),) |
| 17 | $(error $(LOCAL_PATH): Illegal use of OVERRIDE_BUILT_MODULE_PATH) |
| 18 | endif |
Ying Wang | 5f07480 | 2011-11-08 09:31:21 -0800 | [diff] [blame] | 19 | ifneq ($(strip $(LOCAL_MODULE_STEM)$(LOCAL_BUILT_MODULE_STEM)),) |
Ian Rogers | 76a6dc3 | 2012-10-01 16:36:23 -0700 | [diff] [blame] | 20 | $(error $(LOCAL_PATH): Cannot set module stem for a library) |
Ying Wang | 5f07480 | 2011-11-08 09:31:21 -0800 | [diff] [blame] | 21 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 22 | |
Ying Wang | 4c49372 | 2013-01-15 15:28:08 -0800 | [diff] [blame] | 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))) |
| 28 | include $(BUILD_PREBUILT) |
| 29 | skip_build_from_source := true |
| 30 | endif |
| 31 | endif |
| 32 | |
| 33 | ifndef skip_build_from_source |
Kito Cheng | 70dc3e1 | 2012-06-15 15:15:50 +0800 | [diff] [blame] | 34 | #################################################### |
| 35 | ## Add profiling libraries if aprof is turned |
| 36 | #################################################### |
| 37 | ifeq ($(strip $(LOCAL_ENABLE_APROF_JNI)),true) |
| 38 | LOCAL_ENABLE_APROF := true |
| 39 | LOCAL_WHOLE_STATIC_LIBRARIES += libaprof_jni |
| 40 | endif |
| 41 | |
| 42 | ifeq ($(strip $(LOCAL_ENABLE_APROF)),true) |
| 43 | LOCAL_SHARED_LIBRARIES += libaprof libaprof_runtime |
| 44 | endif |
| 45 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 46 | # Put the built targets of all shared libraries in a common directory |
| 47 | # to simplify the link line. |
| 48 | OVERRIDE_BUILT_MODULE_PATH := $(TARGET_OUT_INTERMEDIATE_LIBRARIES) |
| 49 | |
| 50 | include $(BUILD_SYSTEM)/dynamic_binary.mk |
| 51 | |
Kito Cheng | 70dc3e1 | 2012-06-15 15:15:50 +0800 | [diff] [blame] | 52 | |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 53 | # Define PRIVATE_ variables from global vars |
| 54 | my_target_global_ld_dirs := $(TARGET_GLOBAL_LD_DIRS) |
| 55 | my_target_global_ldflags := $(TARGET_GLOBAL_LDFLAGS) |
| 56 | my_target_fdo_lib := $(TARGET_FDO_LIB) |
| 57 | my_target_libgcc := $(TARGET_LIBGCC) |
| 58 | my_target_crtbegin_so_o := $(TARGET_CRTBEGIN_SO_O) |
| 59 | my_target_crtend_so_o := $(TARGET_CRTEND_SO_O) |
Ying Wang | 54fdb47 | 2012-08-14 10:13:16 -0700 | [diff] [blame] | 60 | ifdef LOCAL_SDK_VERSION |
Ying Wang | b934e49 | 2011-07-20 15:42:53 -0700 | [diff] [blame] | 61 | # Make sure the prebuilt NDK paths are put ahead of the TARGET_GLOBAL_LD_DIRS, |
| 62 | # so we don't have race condition when the system libraries (such as libc, libstdc++) are also built in the tree. |
| 63 | my_target_global_ld_dirs := \ |
| 64 | $(addprefix -L, $(patsubst %/,%,$(dir $(my_ndk_stl_shared_lib_fullpath))) \ |
| 65 | $(my_ndk_version_root)/usr/lib) \ |
| 66 | $(my_target_global_ld_dirs) |
Ying Wang | cce4c97 | 2011-03-03 18:53:53 -0800 | [diff] [blame] | 67 | my_target_global_ldflags := $(my_ndk_stl_shared_lib) $(my_target_global_ldflags) |
Ying Wang | 7ee6c40 | 2011-03-04 11:21:38 -0800 | [diff] [blame] | 68 | my_target_crtbegin_so_o := $(wildcard $(my_ndk_version_root)/usr/lib/crtbegin_so.o) |
| 69 | my_target_crtend_so_o := $(wildcard $(my_ndk_version_root)/usr/lib/crtend_so.o) |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 70 | endif |
| 71 | $(linked_module): PRIVATE_TARGET_GLOBAL_LD_DIRS := $(my_target_global_ld_dirs) |
| 72 | $(linked_module): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags) |
| 73 | $(linked_module): PRIVATE_TARGET_FDO_LIB := $(my_target_fdo_lib) |
| 74 | $(linked_module): PRIVATE_TARGET_LIBGCC := $(my_target_libgcc) |
| 75 | $(linked_module): PRIVATE_TARGET_CRTBEGIN_SO_O := $(my_target_crtbegin_so_o) |
| 76 | $(linked_module): PRIVATE_TARGET_CRTEND_SO_O := $(my_target_crtend_so_o) |
| 77 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 78 | $(linked_module): $(all_objects) $(all_libraries) \ |
| 79 | $(LOCAL_ADDITIONAL_DEPENDENCIES) \ |
Ying Wang | 1a08100 | 2010-07-13 14:55:47 -0700 | [diff] [blame] | 80 | $(my_target_crtbegin_so_o) $(my_target_crtend_so_o) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 81 | $(transform-o-to-shared-lib) |
Ying Wang | 4c49372 | 2013-01-15 15:28:08 -0800 | [diff] [blame] | 82 | |
| 83 | endif # skip_build_from_source |