• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1###########################################################
2## Standard rules for building an executable file.
3##
4## Additional inputs from base_rules.make:
5## None.
6###########################################################
7
8ifeq ($(strip $(LOCAL_MODULE_CLASS)),)
9LOCAL_MODULE_CLASS := EXECUTABLES
10endif
11ifeq ($(strip $(LOCAL_MODULE_SUFFIX)),)
12LOCAL_MODULE_SUFFIX := $(TARGET_EXECUTABLE_SUFFIX)
13endif
14
15ifdef target-executable-hook
16$(call target-executable-hook)
17endif
18
19skip_build_from_source :=
20ifdef LOCAL_PREBUILT_MODULE_FILE
21ifeq (,$(call if-build-from-source,$(LOCAL_MODULE),$(LOCAL_PATH)))
22include $(BUILD_SYSTEM)/prebuilt_internal.mk
23skip_build_from_source := true
24endif
25endif
26
27ifndef skip_build_from_source
28
29include $(BUILD_SYSTEM)/dynamic_binary.mk
30
31# Check for statically linked libc
32ifneq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
33ifneq ($(filter $(my_static_libraries),libc),)
34$(error $(LOCAL_PATH): $(LOCAL_MODULE) is statically linking libc to dynamic executable, please remove libc from static libs or set LOCAL_FORCE_STATIC_EXECUTABLE := true)
35endif
36endif
37
38# Define PRIVATE_ variables from global vars
39ifeq ($(LOCAL_NO_LIBCRT_BUILTINS),true)
40my_target_libcrt_builtins :=
41else
42my_target_libcrt_builtins := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBCRT_BUILTINS)
43endif
44ifeq ($(LOCAL_NO_LIBGCC),true)
45my_target_libgcc :=
46else
47my_target_libgcc := $(call intermediates-dir-for,STATIC_LIBRARIES,libgcc,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libgcc.a
48endif
49my_target_libatomic := $(call intermediates-dir-for,STATIC_LIBRARIES,libatomic,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libatomic.a
50ifeq ($(LOCAL_NO_CRT),true)
51my_target_crtbegin_dynamic_o :=
52my_target_crtbegin_static_o :=
53my_target_crtend_o :=
54else ifdef LOCAL_USE_VNDK
55my_target_crtbegin_dynamic_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtbegin_dynamic.vendor)
56my_target_crtbegin_static_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtbegin_static.vendor)
57my_target_crtend_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtend_android.vendor)
58else
59my_target_crtbegin_dynamic_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtbegin_dynamic)
60my_target_crtbegin_static_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtbegin_static)
61my_target_crtend_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtend_android)
62endif
63ifneq ($(LOCAL_SDK_VERSION),)
64my_target_crtbegin_dynamic_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_dynamic.o)
65my_target_crtbegin_static_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_static.o)
66my_target_crtend_o := $(wildcard $(my_ndk_sysroot_lib)/crtend_android.o)
67endif
68$(linked_module): PRIVATE_TARGET_LIBCRT_BUILTINS := $(my_target_libcrt_builtins)
69$(linked_module): PRIVATE_TARGET_LIBGCC := $(my_target_libgcc)
70$(linked_module): PRIVATE_TARGET_LIBATOMIC := $(my_target_libatomic)
71$(linked_module): PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O := $(my_target_crtbegin_dynamic_o)
72$(linked_module): PRIVATE_TARGET_CRTBEGIN_STATIC_O := $(my_target_crtbegin_static_o)
73$(linked_module): PRIVATE_TARGET_CRTEND_O := $(my_target_crtend_o)
74$(linked_module): PRIVATE_POST_LINK_CMD := $(LOCAL_POST_LINK_CMD)
75
76ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
77$(linked_module): $(my_target_crtbegin_static_o) $(all_objects) $(all_libraries) $(my_target_crtend_o) $(my_target_libcrt_builtins) $(my_target_libgcc) $(my_target_libatomic)
78	$(transform-o-to-static-executable)
79	$(PRIVATE_POST_LINK_CMD)
80else
81$(linked_module): $(my_target_crtbegin_dynamic_o) $(all_objects) $(all_libraries) $(my_target_crtend_o) $(my_target_libcrt_builtins) $(my_target_libgcc) $(my_target_libatomic)
82	$(transform-o-to-executable)
83	$(PRIVATE_POST_LINK_CMD)
84endif
85
86ifeq ($(my_native_coverage),true)
87gcno_suffix := .gcnodir
88
89built_whole_gcno_libraries := \
90    $(foreach lib,$(my_whole_static_libraries), \
91      $(call intermediates-dir-for, \
92        STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX), \
93        $(my_host_cross))/$(lib)$(gcno_suffix))
94
95built_static_gcno_libraries := \
96    $(foreach lib,$(my_static_libraries), \
97      $(call intermediates-dir-for, \
98        STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX), \
99        $(my_host_cross))/$(lib)$(gcno_suffix))
100
101ifdef LOCAL_IS_HOST_MODULE
102my_coverage_path := $($(my_prefix)OUT_COVERAGE)/$(patsubst $($(my_prefix)OUT)/%,%,$(my_module_path))
103else
104my_coverage_path := $(TARGET_OUT_COVERAGE)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path))
105endif
106
107GCNO_ARCHIVE := $(my_installed_module_stem)$(gcno_suffix)
108
109$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_OBJECTS := $(strip $(LOCAL_GCNO_FILES))
110$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(strip $(built_whole_gcno_libraries)) $(strip $(built_static_gcno_libraries))
111$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_INTERMEDIATES_DIR := $(intermediates)
112$(intermediates)/$(GCNO_ARCHIVE) : $(LOCAL_GCNO_FILES) $(built_whole_gcno_libraries) $(built_static_gcno_libraries)
113	$(transform-o-to-static-lib)
114
115$(my_coverage_path)/$(GCNO_ARCHIVE) : $(intermediates)/$(GCNO_ARCHIVE)
116	$(copy-file-to-target)
117
118$(LOCAL_BUILT_MODULE): $(my_coverage_path)/$(GCNO_ARCHIVE)
119endif
120
121endif  # skip_build_from_source
122