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_libgcc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCC) 39my_target_libatomic := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBATOMIC) 40my_target_crtbegin_dynamic_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_CRTBEGIN_DYNAMIC_O) 41my_target_crtbegin_static_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_CRTBEGIN_STATIC_O) 42my_target_crtend_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_CRTEND_O) 43ifdef LOCAL_SDK_VERSION 44# Make sure the prebuilt NDK paths are put ahead of the TARGET_GLOBAL_LD_DIRS, 45# so we don't have race condition when the system libraries (such as libc, libstdc++) are also built in the tree. 46my_target_global_ld_dirs := \ 47 $(addprefix -L, $(patsubst %/,%,$(dir $(my_ndk_stl_shared_lib_fullpath))) \ 48 $(my_ndk_sysroot_lib)) \ 49 $(my_target_global_ld_dirs) 50my_target_global_ldflags := $(my_ndk_stl_shared_lib) $(my_target_global_ldflags) 51my_target_crtbegin_dynamic_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_dynamic.o) 52my_target_crtbegin_static_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_static.o) 53my_target_crtend_o := $(wildcard $(my_ndk_sysroot_lib)/crtend_android.o) 54endif 55$(linked_module): PRIVATE_TARGET_GLOBAL_LD_DIRS := $(my_target_global_ld_dirs) 56$(linked_module): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags) 57$(linked_module): PRIVATE_TARGET_LIBGCC := $(my_target_libgcc) 58$(linked_module): PRIVATE_TARGET_LIBATOMIC := $(my_target_libatomic) 59$(linked_module): PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O := $(my_target_crtbegin_dynamic_o) 60$(linked_module): PRIVATE_TARGET_CRTBEGIN_STATIC_O := $(my_target_crtbegin_static_o) 61$(linked_module): PRIVATE_TARGET_CRTEND_O := $(my_target_crtend_o) 62$(linked_module): PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES) 63 64ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true) 65$(linked_module): $(my_target_crtbegin_static_o) $(all_objects) $(all_libraries) $(my_target_crtend_o) 66 $(transform-o-to-static-executable) 67else 68$(linked_module): $(my_target_crtbegin_dynamic_o) $(all_objects) $(all_libraries) $(my_target_crtend_o) 69 $(transform-o-to-executable) 70endif 71 72endif # skip_build_from_source 73