OSDN Git Service

am 2cb0549a: Reconcile with jb-dev
[android-x86/build.git] / core / shared_library.mk
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
19 ifneq ($(strip $(LOCAL_MODULE_STEM)$(LOCAL_BUILT_MODULE_STEM)),)
20 $(error $(LOCAL_PATH): Cannot set module stem for a library)
21 endif
22
23 ####################################################
24 ## Add profiling libraries if aprof is turned
25 ####################################################
26 ifeq ($(strip $(LOCAL_ENABLE_APROF_JNI)),true)
27   LOCAL_ENABLE_APROF := true
28   LOCAL_WHOLE_STATIC_LIBRARIES += libaprof_jni
29 endif
30
31 ifeq ($(strip $(LOCAL_ENABLE_APROF)),true)
32   LOCAL_SHARED_LIBRARIES += libaprof libaprof_runtime
33 endif
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 := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)
38
39 include $(BUILD_SYSTEM)/dynamic_binary.mk
40
41
42 # Define PRIVATE_ variables from global vars
43 my_target_global_ld_dirs := $(TARGET_GLOBAL_LD_DIRS)
44 my_target_global_ldflags := $(TARGET_GLOBAL_LDFLAGS)
45 my_target_fdo_lib := $(TARGET_FDO_LIB)
46 my_target_libgcc := $(TARGET_LIBGCC)
47 my_target_crtbegin_so_o := $(TARGET_CRTBEGIN_SO_O)
48 my_target_crtend_so_o := $(TARGET_CRTEND_SO_O)
49 ifdef LOCAL_SDK_VERSION
50 # Make sure the prebuilt NDK paths are put ahead of the TARGET_GLOBAL_LD_DIRS,
51 # so we don't have race condition when the system libraries (such as libc, libstdc++) are also built in the tree.
52 my_target_global_ld_dirs := \
53     $(addprefix -L, $(patsubst %/,%,$(dir $(my_ndk_stl_shared_lib_fullpath))) \
54     $(my_ndk_version_root)/usr/lib) \
55     $(my_target_global_ld_dirs)
56 my_target_global_ldflags := $(my_ndk_stl_shared_lib) $(my_target_global_ldflags)
57 my_target_crtbegin_so_o := $(wildcard $(my_ndk_version_root)/usr/lib/crtbegin_so.o)
58 my_target_crtend_so_o := $(wildcard $(my_ndk_version_root)/usr/lib/crtend_so.o)
59 endif
60 $(linked_module): PRIVATE_TARGET_GLOBAL_LD_DIRS := $(my_target_global_ld_dirs)
61 $(linked_module): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
62 $(linked_module): PRIVATE_TARGET_FDO_LIB := $(my_target_fdo_lib)
63 $(linked_module): PRIVATE_TARGET_LIBGCC := $(my_target_libgcc)
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): $(all_objects) $(all_libraries) \
68                   $(LOCAL_ADDITIONAL_DEPENDENCIES) \
69                   $(my_target_crtbegin_so_o) $(my_target_crtend_so_o)
70         $(transform-o-to-shared-lib)