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