OSDN Git Service

Merge "Adjust samples output pages." into klp-dev
[android-x86/build.git] / core / executable.mk
1 ###########################################################
2 ## Standard rules for building an executable file.
3 ##
4 ## Additional inputs from base_rules.make:
5 ## None.
6 ###########################################################
7
8 ifeq ($(strip $(LOCAL_MODULE_CLASS)),)
9 LOCAL_MODULE_CLASS := EXECUTABLES
10 endif
11 ifeq ($(strip $(LOCAL_MODULE_SUFFIX)),)
12 LOCAL_MODULE_SUFFIX := $(TARGET_EXECUTABLE_SUFFIX)
13 endif
14
15 $(call target-executable-hook)
16
17 skip_build_from_source :=
18 ifdef LOCAL_PREBUILT_MODULE_FILE
19 ifeq (,$(call if-build-from-source,$(LOCAL_MODULE),$(LOCAL_PATH)))
20 include $(BUILD_PREBUILT)
21 skip_build_from_source := true
22 endif
23 endif
24
25 ifndef skip_build_from_source
26 ####################################################
27 ## Add profiling libraries if aprof is turned
28 ####################################################
29 ifeq ($(strip $(LOCAL_ENABLE_APROF)),true)
30   ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE), true)
31     LOCAL_STATIC_LIBRARIES += libaprof libaprof_static libc libcutils
32   else
33     LOCAL_SHARED_LIBRARIES += libaprof libaprof_runtime libc
34   endif
35   LOCAL_WHOLE_STATIC_LIBRARIES += libaprof_aux
36 endif
37
38 include $(BUILD_SYSTEM)/dynamic_binary.mk
39
40 # Define PRIVATE_ variables from global vars
41 my_target_global_ld_dirs := $(TARGET_GLOBAL_LD_DIRS)
42 my_target_global_ldflags := $(TARGET_GLOBAL_LDFLAGS)
43 my_target_fdo_lib := $(TARGET_FDO_LIB)
44 my_target_libgcc := $(TARGET_LIBGCC)
45 my_target_crtbegin_dynamic_o := $(TARGET_CRTBEGIN_DYNAMIC_O)
46 my_target_crtbegin_static_o := $(TARGET_CRTBEGIN_STATIC_O)
47 my_target_crtend_o := $(TARGET_CRTEND_O)
48 ifdef LOCAL_SDK_VERSION
49 # Make sure the prebuilt NDK paths are put ahead of the TARGET_GLOBAL_LD_DIRS,
50 # so we don't have race condition when the system libraries (such as libc, libstdc++) are also built in the tree.
51 my_target_global_ld_dirs := \
52     $(addprefix -L, $(patsubst %/,%,$(dir $(my_ndk_stl_shared_lib_fullpath))) \
53     $(my_ndk_version_root)/usr/lib) \
54     $(my_target_global_ld_dirs)
55 my_target_global_ldflags := $(my_ndk_stl_shared_lib) $(my_target_global_ldflags)
56 my_target_crtbegin_dynamic_o := $(wildcard $(my_ndk_version_root)/usr/lib/crtbegin_dynamic.o)
57 my_target_crtbegin_static_o := $(wildcard $(my_ndk_version_root)/usr/lib/crtbegin_static.o)
58 my_target_crtend_o := $(wildcard $(my_ndk_version_root)/usr/lib/crtend_android.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_DYNAMIC_O := $(my_target_crtbegin_dynamic_o)
65 $(linked_module): PRIVATE_TARGET_CRTBEGIN_STATIC_O := $(my_target_crtbegin_static_o)
66 $(linked_module): PRIVATE_TARGET_CRTEND_O := $(my_target_crtend_o)
67
68 ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
69 $(linked_module): $(my_target_crtbegin_static_o) $(all_objects) $(all_libraries) $(my_target_crtend_o)
70         $(transform-o-to-static-executable)
71 else
72 $(linked_module): $(my_target_crtbegin_dynamic_o) $(all_objects) $(all_libraries) $(my_target_crtend_o)
73         $(transform-o-to-executable)
74 endif
75
76 endif  # skip_build_from_source