1# We don't automatically set up rules to build executables for both 2# TARGET_ARCH and TARGET_2ND_ARCH. 3# By default, an executable is built for TARGET_ARCH. 4# To build it for TARGET_2ND_ARCH in a 64bit product, use "LOCAL_MULTILIB := 32" 5# To build it for both set LOCAL_MULTILIB := both and specify 6# LOCAL_MODULE_PATH_32 and LOCAL_MODULE_PATH_64 or LOCAL_MODULE_STEM_32 and 7# LOCAL_MODULE_STEM_64 8 9my_skip_this_target := 10ifneq ($(filter address,$(SANITIZE_TARGET)),) 11 ifeq (true,$(LOCAL_FORCE_STATIC_EXECUTABLE)) 12 my_skip_this_target := true 13 else ifeq (false, $(LOCAL_CLANG)) 14 my_skip_this_target := true 15 endif 16endif 17 18ifneq (true,$(my_skip_this_target)) 19$(call record-module-type,EXECUTABLE) 20 21ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true) 22# If a native test explicity specifies to build only for the translation arch, 23# we'll still need LOCAL_MULTILIB=both and let module_arch_supported.mk choose 24# to build only for TARGET_2ND_ARCH. 25ifneq (1,$(words $(LOCAL_MODULE_TARGET_ARCH))) 26LOCAL_MULTILIB := first 27endif 28endif 29 30my_prefix := TARGET_ 31include $(BUILD_SYSTEM)/multilib.mk 32 33ifeq ($(my_module_multilib),both) 34ifneq ($(LOCAL_MODULE_CLASS),NATIVE_TESTS) 35ifeq ($(LOCAL_MODULE_PATH_32)$(LOCAL_MODULE_STEM_32),) 36$(error $(LOCAL_PATH): LOCAL_MODULE_STEM_32 or LOCAL_MODULE_PATH_32 is required for LOCAL_MULTILIB := both for module $(LOCAL_MODULE)) 37endif 38ifeq ($(LOCAL_MODULE_PATH_64)$(LOCAL_MODULE_STEM_64),) 39$(error $(LOCAL_PATH): LOCAL_MODULE_STEM_64 or LOCAL_MODULE_PATH_64 is required for LOCAL_MULTILIB := both for module $(LOCAL_MODULE)) 40endif 41endif 42else #!LOCAL_MULTILIB == both 43LOCAL_NO_2ND_ARCH_MODULE_SUFFIX := true 44endif 45 46# if TARGET_PREFER_32_BIT_EXECUTABLES is set, try to build 32-bit first 47ifdef TARGET_2ND_ARCH 48ifeq ($(TARGET_PREFER_32_BIT_EXECUTABLES),true) 49LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX) 50else 51LOCAL_2ND_ARCH_VAR_PREFIX := 52endif 53endif 54 55my_skip_non_preferred_arch := 56 57# check if preferred arch is supported 58include $(BUILD_SYSTEM)/module_arch_supported.mk 59ifeq ($(my_module_arch_supported),true) 60# first arch is supported 61include $(BUILD_SYSTEM)/executable_internal.mk 62ifneq ($(my_module_multilib),both) 63my_skip_non_preferred_arch := true 64endif 65endif 66 67# check if preferred arch was not supported or asked to build both 68ifndef my_skip_non_preferred_arch 69ifdef TARGET_2ND_ARCH 70 71# check if the non-preferred arch is the primary or secondary 72ifeq ($(TARGET_PREFER_32_BIT_EXECUTABLES),true) 73LOCAL_2ND_ARCH_VAR_PREFIX := 74else 75LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX) 76endif 77 78# check if non-preferred arch is supported 79include $(BUILD_SYSTEM)/module_arch_supported.mk 80ifeq ($(my_module_arch_supported),true) 81# non-preferred arch is supported 82OVERRIDE_BUILT_MODULE_PATH := 83LOCAL_BUILT_MODULE := 84LOCAL_INSTALLED_MODULE := 85LOCAL_INTERMEDIATE_TARGETS := 86include $(BUILD_SYSTEM)/executable_internal.mk 87endif 88endif # TARGET_2ND_ARCH 89endif # !my_skip_non_preferred_arch || LOCAL_MULTILIB 90LOCAL_2ND_ARCH_VAR_PREFIX := 91LOCAL_NO_2ND_ARCH_MODULE_SUFFIX := 92 93my_module_arch_supported := 94 95endif 96