Ying Wang | dd814bf | 2014-01-17 16:17:28 -0800 | [diff] [blame] | 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 | |
Dan Willemsen | 893bebc | 2018-01-29 16:18:40 -0800 | [diff] [blame] | 15 | ifdef target-executable-hook |
Ying Wang | dd814bf | 2014-01-17 16:17:28 -0800 | [diff] [blame] | 16 | $(call target-executable-hook) |
Dan Willemsen | 893bebc | 2018-01-29 16:18:40 -0800 | [diff] [blame] | 17 | endif |
Ying Wang | dd814bf | 2014-01-17 16:17:28 -0800 | [diff] [blame] | 18 | |
| 19 | skip_build_from_source := |
| 20 | ifdef LOCAL_PREBUILT_MODULE_FILE |
| 21 | ifeq (,$(call if-build-from-source,$(LOCAL_MODULE),$(LOCAL_PATH))) |
Ying Wang | 58f462f | 2014-02-25 18:26:29 -0800 | [diff] [blame] | 22 | include $(BUILD_SYSTEM)/prebuilt_internal.mk |
Ying Wang | dd814bf | 2014-01-17 16:17:28 -0800 | [diff] [blame] | 23 | skip_build_from_source := true |
| 24 | endif |
| 25 | endif |
| 26 | |
| 27 | ifndef skip_build_from_source |
| 28 | |
| 29 | include $(BUILD_SYSTEM)/dynamic_binary.mk |
| 30 | |
Dmitriy Ivanov | 655d685 | 2014-08-15 11:30:23 -0700 | [diff] [blame] | 31 | # Check for statically linked libc |
| 32 | ifneq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true) |
| 33 | ifneq ($(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) |
| 35 | endif |
| 36 | endif |
| 37 | |
Ying Wang | dd814bf | 2014-01-17 16:17:28 -0800 | [diff] [blame] | 38 | # Define PRIVATE_ variables from global vars |
Yi Kong | 2b7e980 | 2018-11-06 12:59:32 -0800 | [diff] [blame] | 39 | ifeq ($(LOCAL_NO_LIBCRT_BUILTINS),true) |
| 40 | my_target_libcrt_builtins := |
| 41 | else |
Yi Kong | 95fd9d1 | 2018-10-12 16:58:57 -0700 | [diff] [blame] | 42 | my_target_libcrt_builtins := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBCRT_BUILTINS) |
Yi Kong | 2b7e980 | 2018-11-06 12:59:32 -0800 | [diff] [blame] | 43 | endif |
Ying Wang | 75011b2 | 2015-07-02 11:05:27 -0700 | [diff] [blame] | 44 | ifeq ($(LOCAL_NO_LIBGCC),true) |
| 45 | my_target_libgcc := |
| 46 | else |
Dan Willemsen | db16dd2 | 2016-05-16 14:41:49 -0700 | [diff] [blame] | 47 | 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] | 48 | endif |
Dan Willemsen | db16dd2 | 2016-05-16 14:41:49 -0700 | [diff] [blame] | 49 | 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] | 50 | ifeq ($(LOCAL_NO_CRT),true) |
| 51 | my_target_crtbegin_dynamic_o := |
| 52 | my_target_crtbegin_static_o := |
| 53 | my_target_crtend_o := |
Dan Willemsen | 9d2b328 | 2017-04-07 20:58:43 -0700 | [diff] [blame] | 54 | else ifdef LOCAL_USE_VNDK |
Dan Willemsen | 8cf6b65 | 2018-09-05 11:01:12 -0700 | [diff] [blame] | 55 | my_target_crtbegin_dynamic_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtbegin_dynamic.vendor) |
| 56 | my_target_crtbegin_static_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtbegin_static.vendor) |
| 57 | my_target_crtend_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtend_android.vendor) |
Ying Wang | 491fca9 | 2015-07-02 15:57:45 -0700 | [diff] [blame] | 58 | else |
Dan Willemsen | 8cf6b65 | 2018-09-05 11:01:12 -0700 | [diff] [blame] | 59 | my_target_crtbegin_dynamic_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtbegin_dynamic) |
| 60 | my_target_crtbegin_static_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtbegin_static) |
| 61 | my_target_crtend_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtend_android) |
Ying Wang | 491fca9 | 2015-07-02 15:57:45 -0700 | [diff] [blame] | 62 | endif |
Dan Willemsen | 9d2b328 | 2017-04-07 20:58:43 -0700 | [diff] [blame] | 63 | ifneq ($(LOCAL_SDK_VERSION),) |
Andrew Hsieh | 140761af0 | 2014-04-25 23:47:10 -0700 | [diff] [blame] | 64 | my_target_crtbegin_dynamic_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_dynamic.o) |
| 65 | my_target_crtbegin_static_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_static.o) |
| 66 | my_target_crtend_o := $(wildcard $(my_ndk_sysroot_lib)/crtend_android.o) |
Ying Wang | dd814bf | 2014-01-17 16:17:28 -0800 | [diff] [blame] | 67 | endif |
Yi Kong | 95fd9d1 | 2018-10-12 16:58:57 -0700 | [diff] [blame] | 68 | $(linked_module): PRIVATE_TARGET_LIBCRT_BUILTINS := $(my_target_libcrt_builtins) |
Ying Wang | dd814bf | 2014-01-17 16:17:28 -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 | dd814bf | 2014-01-17 16:17:28 -0800 | [diff] [blame] | 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) |
Yabin Cui | 273e910 | 2016-03-02 14:03:41 -0800 | [diff] [blame] | 74 | $(linked_module): PRIVATE_POST_LINK_CMD := $(LOCAL_POST_LINK_CMD) |
Ying Wang | dd814bf | 2014-01-17 16:17:28 -0800 | [diff] [blame] | 75 | |
| 76 | ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true) |
Dan Willemsen | c5b7c4f | 2019-06-12 05:59:53 +0000 | [diff] [blame] | 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) $(CLANG_CXX) |
Ying Wang | dd814bf | 2014-01-17 16:17:28 -0800 | [diff] [blame] | 78 | $(transform-o-to-static-executable) |
Ying Wang | 8b34769 | 2014-09-05 15:46:43 -0700 | [diff] [blame] | 79 | $(PRIVATE_POST_LINK_CMD) |
Ying Wang | dd814bf | 2014-01-17 16:17:28 -0800 | [diff] [blame] | 80 | else |
Dan Willemsen | c5b7c4f | 2019-06-12 05:59:53 +0000 | [diff] [blame] | 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) $(CLANG_CXX) |
Ying Wang | dd814bf | 2014-01-17 16:17:28 -0800 | [diff] [blame] | 82 | $(transform-o-to-executable) |
Yabin Cui | 273e910 | 2016-03-02 14:03:41 -0800 | [diff] [blame] | 83 | $(PRIVATE_POST_LINK_CMD) |
Ying Wang | dd814bf | 2014-01-17 16:17:28 -0800 | [diff] [blame] | 84 | endif |
| 85 | |
Ryan Campbell | 14827f2 | 2017-11-07 09:50:59 -0800 | [diff] [blame] | 86 | ifeq ($(my_native_coverage),true) |
Oliver Nguyen | e91ab23 | 2019-04-30 15:14:44 -0700 | [diff] [blame] | 87 | gcno_suffix := .zip |
Ryan Campbell | 14827f2 | 2017-11-07 09:50:59 -0800 | [diff] [blame] | 88 | |
| 89 | built_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 | |
| 95 | built_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 | |
| 101 | ifdef LOCAL_IS_HOST_MODULE |
| 102 | my_coverage_path := $($(my_prefix)OUT_COVERAGE)/$(patsubst $($(my_prefix)OUT)/%,%,$(my_module_path)) |
| 103 | else |
| 104 | my_coverage_path := $(TARGET_OUT_COVERAGE)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path)) |
| 105 | endif |
| 106 | |
| 107 | GCNO_ARCHIVE := $(my_installed_module_stem)$(gcno_suffix) |
| 108 | |
Oliver Nguyen | e91ab23 | 2019-04-30 15:14:44 -0700 | [diff] [blame] | 109 | $(intermediates)/$(GCNO_ARCHIVE) : $(SOONG_ZIP) $(MERGE_ZIPS) |
Ryan Campbell | 14827f2 | 2017-11-07 09:50:59 -0800 | [diff] [blame] | 110 | $(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_OBJECTS := $(strip $(LOCAL_GCNO_FILES)) |
| 111 | $(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(strip $(built_whole_gcno_libraries)) $(strip $(built_static_gcno_libraries)) |
Ryan Campbell | 14827f2 | 2017-11-07 09:50:59 -0800 | [diff] [blame] | 112 | $(intermediates)/$(GCNO_ARCHIVE) : $(LOCAL_GCNO_FILES) $(built_whole_gcno_libraries) $(built_static_gcno_libraries) |
Oliver Nguyen | e91ab23 | 2019-04-30 15:14:44 -0700 | [diff] [blame] | 113 | $(package-coverage-files) |
Ryan Campbell | 14827f2 | 2017-11-07 09:50:59 -0800 | [diff] [blame] | 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) |
| 119 | endif |
| 120 | |
Ying Wang | dd814bf | 2014-01-17 16:17:28 -0800 | [diff] [blame] | 121 | endif # skip_build_from_source |