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_CRT),true) 45my_target_crtbegin_dynamic_o := 46my_target_crtbegin_static_o := 47my_target_crtend_o := 48else ifdef LOCAL_USE_VNDK 49my_target_crtbegin_dynamic_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtbegin_dynamic.vendor) 50my_target_crtbegin_static_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtbegin_static.vendor) 51my_target_crtend_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtend_android.vendor) 52else 53my_target_crtbegin_dynamic_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtbegin_dynamic) 54my_target_crtbegin_static_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtbegin_static) 55my_target_crtend_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtend_android) 56endif 57ifneq ($(LOCAL_SDK_VERSION),) 58my_target_crtbegin_dynamic_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtbegin_dynamic.sdk.$(my_ndk_crt_version)) 59my_target_crtbegin_static_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtbegin_static.sdk.$(my_ndk_crt_version)) 60my_target_crtend_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtend_android.sdk.$(my_ndk_crt_version)) 61endif 62$(linked_module): PRIVATE_TARGET_LIBCRT_BUILTINS := $(my_target_libcrt_builtins) 63$(linked_module): PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O := $(my_target_crtbegin_dynamic_o) 64$(linked_module): PRIVATE_TARGET_CRTBEGIN_STATIC_O := $(my_target_crtbegin_static_o) 65$(linked_module): PRIVATE_TARGET_CRTEND_O := $(my_target_crtend_o) 66$(linked_module): PRIVATE_POST_LINK_CMD := $(LOCAL_POST_LINK_CMD) 67 68ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true) 69$(linked_module): $(my_target_crtbegin_static_o) $(all_objects) $(all_libraries) $(my_target_crtend_o) $(my_target_libcrt_builtins) $(CLANG_CXX) 70 $(transform-o-to-static-executable) 71 $(PRIVATE_POST_LINK_CMD) 72else 73$(linked_module): $(my_target_crtbegin_dynamic_o) $(all_objects) $(all_libraries) $(my_target_crtend_o) $(my_target_libcrt_builtins) $(CLANG_CXX) 74 $(transform-o-to-executable) 75 $(PRIVATE_POST_LINK_CMD) 76endif 77 78ifeq ($(my_native_coverage),true) 79gcno_suffix := .zip 80 81built_whole_gcno_libraries := \ 82 $(foreach lib,$(my_whole_static_libraries), \ 83 $(call intermediates-dir-for, \ 84 STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX), \ 85 $(my_host_cross))/$(lib)$(gcno_suffix)) 86 87built_static_gcno_libraries := \ 88 $(foreach lib,$(my_static_libraries), \ 89 $(call intermediates-dir-for, \ 90 STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX), \ 91 $(my_host_cross))/$(lib)$(gcno_suffix)) 92 93ifdef LOCAL_IS_HOST_MODULE 94my_coverage_path := $($(my_prefix)OUT_COVERAGE)/$(patsubst $($(my_prefix)OUT)/%,%,$(my_module_path)) 95else 96my_coverage_path := $(TARGET_OUT_COVERAGE)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path)) 97endif 98 99GCNO_ARCHIVE := $(my_installed_module_stem)$(gcno_suffix) 100 101$(intermediates)/$(GCNO_ARCHIVE) : $(SOONG_ZIP) $(MERGE_ZIPS) 102$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_OBJECTS := $(strip $(LOCAL_GCNO_FILES)) 103$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(strip $(built_whole_gcno_libraries)) $(strip $(built_static_gcno_libraries)) 104$(intermediates)/$(GCNO_ARCHIVE) : $(LOCAL_GCNO_FILES) $(built_whole_gcno_libraries) $(built_static_gcno_libraries) 105 $(package-coverage-files) 106 107$(my_coverage_path)/$(GCNO_ARCHIVE) : $(intermediates)/$(GCNO_ARCHIVE) 108 $(copy-file-to-target) 109 110$(LOCAL_BUILT_MODULE): $(my_coverage_path)/$(GCNO_ARCHIVE) 111endif 112 113endif # skip_build_from_source 114