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 15$(call target-executable-hook) 16 17skip_build_from_source := 18ifdef LOCAL_PREBUILT_MODULE_FILE 19ifeq (,$(call if-build-from-source,$(LOCAL_MODULE),$(LOCAL_PATH))) 20include $(BUILD_SYSTEM)/prebuilt_internal.mk 21skip_build_from_source := true 22endif 23endif 24 25ifndef skip_build_from_source 26 27include $(BUILD_SYSTEM)/dynamic_binary.mk 28 29# Check for statically linked libc 30ifneq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true) 31ifneq ($(filter $(my_static_libraries),libc),) 32$(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) 33endif 34endif 35 36# Define PRIVATE_ variables from global vars 37my_target_global_ld_dirs := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LD_DIRS) 38my_target_libprofile_rt := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBPROFILE_RT) 39my_target_libgcov := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCOV) 40ifeq ($(LOCAL_NO_LIBGCC),true) 41my_target_libgcc := 42else 43my_target_libgcc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCC) 44endif 45my_target_libatomic := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBATOMIC) 46my_target_crtbegin_dynamic_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_CRTBEGIN_DYNAMIC_O) 47my_target_crtbegin_static_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_CRTBEGIN_STATIC_O) 48my_target_crtend_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_CRTEND_O) 49ifdef LOCAL_SDK_VERSION 50# Make sure the prebuilt NDK paths are put ahead of the TARGET_GLOBAL_LD_DIRS, 51# so we don't have race condition when the system libraries (such as libc, libstdc++) are also built in the tree. 52my_target_global_ld_dirs := \ 53 $(addprefix -L, $(patsubst %/,%,$(dir $(my_ndk_stl_shared_lib_fullpath))) \ 54 $(my_ndk_sysroot_lib)) \ 55 $(my_target_global_ld_dirs) 56my_target_global_ldflags := $(my_ndk_stl_shared_lib) $(my_target_global_ldflags) 57my_target_crtbegin_dynamic_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_dynamic.o) 58my_target_crtbegin_static_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_static.o) 59my_target_crtend_o := $(wildcard $(my_ndk_sysroot_lib)/crtend_android.o) 60endif 61$(linked_module): PRIVATE_TARGET_GLOBAL_LD_DIRS := $(my_target_global_ld_dirs) 62$(linked_module): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags) 63$(linked_module): PRIVATE_TARGET_LIBPROFILE_RT := $(my_target_libprofile_rt) 64$(linked_module): PRIVATE_TARGET_LIBGCOV := $(my_target_libgcov) 65$(linked_module): PRIVATE_TARGET_LIBGCC := $(my_target_libgcc) 66$(linked_module): PRIVATE_TARGET_LIBATOMIC := $(my_target_libatomic) 67$(linked_module): PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O := $(my_target_crtbegin_dynamic_o) 68$(linked_module): PRIVATE_TARGET_CRTBEGIN_STATIC_O := $(my_target_crtbegin_static_o) 69$(linked_module): PRIVATE_TARGET_CRTEND_O := $(my_target_crtend_o) 70$(linked_module): PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES) 71 72ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true) 73$(linked_module): PRIVATE_POST_LINK_CMD := $(LOCAL_POST_LINK_CMD) 74$(linked_module): $(my_target_crtbegin_static_o) $(all_objects) $(all_libraries) $(my_target_crtend_o) 75 $(transform-o-to-static-executable) 76 $(PRIVATE_POST_LINK_CMD) 77else 78$(linked_module): $(my_target_crtbegin_dynamic_o) $(all_objects) $(all_libraries) $(my_target_crtend_o) 79 $(transform-o-to-executable) 80endif 81 82endif # skip_build_from_source 83