2014-01-18 08:17:28 +08:00
|
|
|
###########################################################
|
|
|
|
## Standard rules for building an executable file.
|
|
|
|
##
|
|
|
|
## Additional inputs from base_rules.make:
|
|
|
|
## None.
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
ifeq ($(strip $(LOCAL_MODULE_CLASS)),)
|
|
|
|
LOCAL_MODULE_CLASS := EXECUTABLES
|
|
|
|
endif
|
|
|
|
ifeq ($(strip $(LOCAL_MODULE_SUFFIX)),)
|
|
|
|
LOCAL_MODULE_SUFFIX := $(TARGET_EXECUTABLE_SUFFIX)
|
|
|
|
endif
|
|
|
|
|
2018-01-30 08:18:40 +08:00
|
|
|
ifdef target-executable-hook
|
2014-01-18 08:17:28 +08:00
|
|
|
$(call target-executable-hook)
|
2018-01-30 08:18:40 +08:00
|
|
|
endif
|
2014-01-18 08:17:28 +08:00
|
|
|
|
|
|
|
skip_build_from_source :=
|
|
|
|
ifdef LOCAL_PREBUILT_MODULE_FILE
|
|
|
|
ifeq (,$(call if-build-from-source,$(LOCAL_MODULE),$(LOCAL_PATH)))
|
2014-02-26 10:26:29 +08:00
|
|
|
include $(BUILD_SYSTEM)/prebuilt_internal.mk
|
2014-01-18 08:17:28 +08:00
|
|
|
skip_build_from_source := true
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef skip_build_from_source
|
|
|
|
|
|
|
|
include $(BUILD_SYSTEM)/dynamic_binary.mk
|
|
|
|
|
2014-08-16 02:30:23 +08:00
|
|
|
# Check for statically linked libc
|
|
|
|
ifneq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
|
|
|
|
ifneq ($(filter $(my_static_libraries),libc),)
|
|
|
|
$(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)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2014-01-18 08:17:28 +08:00
|
|
|
# Define PRIVATE_ variables from global vars
|
2018-11-07 04:59:32 +08:00
|
|
|
ifeq ($(LOCAL_NO_LIBCRT_BUILTINS),true)
|
|
|
|
my_target_libcrt_builtins :=
|
|
|
|
else
|
2018-10-13 07:58:57 +08:00
|
|
|
my_target_libcrt_builtins := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBCRT_BUILTINS)
|
2018-11-07 04:59:32 +08:00
|
|
|
endif
|
2015-07-03 02:05:27 +08:00
|
|
|
ifeq ($(LOCAL_NO_LIBGCC),true)
|
|
|
|
my_target_libgcc :=
|
|
|
|
else
|
2016-05-17 05:41:49 +08:00
|
|
|
my_target_libgcc := $(call intermediates-dir-for,STATIC_LIBRARIES,libgcc,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libgcc.a
|
2015-07-03 02:05:27 +08:00
|
|
|
endif
|
2016-05-17 05:41:49 +08:00
|
|
|
my_target_libatomic := $(call intermediates-dir-for,STATIC_LIBRARIES,libatomic,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libatomic.a
|
2015-07-03 06:57:45 +08:00
|
|
|
ifeq ($(LOCAL_NO_CRT),true)
|
|
|
|
my_target_crtbegin_dynamic_o :=
|
|
|
|
my_target_crtbegin_static_o :=
|
|
|
|
my_target_crtend_o :=
|
2017-04-08 11:58:43 +08:00
|
|
|
else ifdef LOCAL_USE_VNDK
|
2018-09-06 02:01:12 +08:00
|
|
|
my_target_crtbegin_dynamic_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtbegin_dynamic.vendor)
|
|
|
|
my_target_crtbegin_static_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtbegin_static.vendor)
|
|
|
|
my_target_crtend_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtend_android.vendor)
|
2015-07-03 06:57:45 +08:00
|
|
|
else
|
2018-09-06 02:01:12 +08:00
|
|
|
my_target_crtbegin_dynamic_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtbegin_dynamic)
|
|
|
|
my_target_crtbegin_static_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtbegin_static)
|
|
|
|
my_target_crtend_o := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJECT_crtend_android)
|
2015-07-03 06:57:45 +08:00
|
|
|
endif
|
2017-04-08 11:58:43 +08:00
|
|
|
ifneq ($(LOCAL_SDK_VERSION),)
|
2014-04-26 14:47:10 +08:00
|
|
|
my_target_crtbegin_dynamic_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_dynamic.o)
|
|
|
|
my_target_crtbegin_static_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_static.o)
|
|
|
|
my_target_crtend_o := $(wildcard $(my_ndk_sysroot_lib)/crtend_android.o)
|
2014-01-18 08:17:28 +08:00
|
|
|
endif
|
2018-10-13 07:58:57 +08:00
|
|
|
$(linked_module): PRIVATE_TARGET_LIBCRT_BUILTINS := $(my_target_libcrt_builtins)
|
2014-01-18 08:17:28 +08:00
|
|
|
$(linked_module): PRIVATE_TARGET_LIBGCC := $(my_target_libgcc)
|
2014-05-29 17:47:27 +08:00
|
|
|
$(linked_module): PRIVATE_TARGET_LIBATOMIC := $(my_target_libatomic)
|
2014-01-18 08:17:28 +08:00
|
|
|
$(linked_module): PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O := $(my_target_crtbegin_dynamic_o)
|
|
|
|
$(linked_module): PRIVATE_TARGET_CRTBEGIN_STATIC_O := $(my_target_crtbegin_static_o)
|
|
|
|
$(linked_module): PRIVATE_TARGET_CRTEND_O := $(my_target_crtend_o)
|
2016-03-03 06:03:41 +08:00
|
|
|
$(linked_module): PRIVATE_POST_LINK_CMD := $(LOCAL_POST_LINK_CMD)
|
2014-01-18 08:17:28 +08:00
|
|
|
|
|
|
|
ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
|
2018-10-13 07:58:57 +08:00
|
|
|
$(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)
|
2014-01-18 08:17:28 +08:00
|
|
|
$(transform-o-to-static-executable)
|
2014-09-06 06:46:43 +08:00
|
|
|
$(PRIVATE_POST_LINK_CMD)
|
2014-01-18 08:17:28 +08:00
|
|
|
else
|
2018-10-13 07:58:57 +08:00
|
|
|
$(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)
|
2014-01-18 08:17:28 +08:00
|
|
|
$(transform-o-to-executable)
|
2016-03-03 06:03:41 +08:00
|
|
|
$(PRIVATE_POST_LINK_CMD)
|
2014-01-18 08:17:28 +08:00
|
|
|
endif
|
|
|
|
|
2017-11-08 01:50:59 +08:00
|
|
|
ifeq ($(my_native_coverage),true)
|
|
|
|
gcno_suffix := .gcnodir
|
|
|
|
|
|
|
|
built_whole_gcno_libraries := \
|
|
|
|
$(foreach lib,$(my_whole_static_libraries), \
|
|
|
|
$(call intermediates-dir-for, \
|
|
|
|
STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX), \
|
|
|
|
$(my_host_cross))/$(lib)$(gcno_suffix))
|
|
|
|
|
|
|
|
built_static_gcno_libraries := \
|
|
|
|
$(foreach lib,$(my_static_libraries), \
|
|
|
|
$(call intermediates-dir-for, \
|
|
|
|
STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX), \
|
|
|
|
$(my_host_cross))/$(lib)$(gcno_suffix))
|
|
|
|
|
|
|
|
ifdef LOCAL_IS_HOST_MODULE
|
|
|
|
my_coverage_path := $($(my_prefix)OUT_COVERAGE)/$(patsubst $($(my_prefix)OUT)/%,%,$(my_module_path))
|
|
|
|
else
|
|
|
|
my_coverage_path := $(TARGET_OUT_COVERAGE)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path))
|
|
|
|
endif
|
|
|
|
|
|
|
|
GCNO_ARCHIVE := $(my_installed_module_stem)$(gcno_suffix)
|
|
|
|
|
|
|
|
$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_OBJECTS := $(strip $(LOCAL_GCNO_FILES))
|
|
|
|
$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(strip $(built_whole_gcno_libraries)) $(strip $(built_static_gcno_libraries))
|
|
|
|
$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_INTERMEDIATES_DIR := $(intermediates)
|
|
|
|
$(intermediates)/$(GCNO_ARCHIVE) : $(LOCAL_GCNO_FILES) $(built_whole_gcno_libraries) $(built_static_gcno_libraries)
|
|
|
|
$(transform-o-to-static-lib)
|
|
|
|
|
|
|
|
$(my_coverage_path)/$(GCNO_ARCHIVE) : $(intermediates)/$(GCNO_ARCHIVE)
|
|
|
|
$(copy-file-to-target)
|
|
|
|
|
|
|
|
$(LOCAL_BUILT_MODULE): $(my_coverage_path)/$(GCNO_ARCHIVE)
|
|
|
|
endif
|
|
|
|
|
2014-01-18 08:17:28 +08:00
|
|
|
endif # skip_build_from_source
|