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 else ifeq (never, $(LOCAL_SANITIZE)) 16 my_skip_this_target := true 17 endif 18endif 19 20ifneq (true,$(my_skip_this_target)) 21$(call record-module-type,EXECUTABLE) 22 23ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true) 24# If a native test explicity specifies to build only for the translation arch, 25# we'll still need LOCAL_MULTILIB=both and let module_arch_supported.mk choose 26# to build only for TARGET_2ND_ARCH. 27ifneq (1,$(words $(LOCAL_MODULE_TARGET_ARCH))) 28LOCAL_MULTILIB := first 29endif 30endif 31 32my_prefix := TARGET_ 33include $(BUILD_SYSTEM)/multilib.mk 34 35ifeq ($(my_module_multilib),both) 36ifneq ($(LOCAL_MODULE_CLASS),NATIVE_TESTS) 37ifeq ($(LOCAL_MODULE_PATH_32)$(LOCAL_MODULE_STEM_32),) 38$(error $(LOCAL_PATH): LOCAL_MODULE_STEM_32 or LOCAL_MODULE_PATH_32 is required for LOCAL_MULTILIB := both for module $(LOCAL_MODULE)) 39endif 40ifeq ($(LOCAL_MODULE_PATH_64)$(LOCAL_MODULE_STEM_64),) 41$(error $(LOCAL_PATH): LOCAL_MODULE_STEM_64 or LOCAL_MODULE_PATH_64 is required for LOCAL_MULTILIB := both for module $(LOCAL_MODULE)) 42endif 43endif 44else #!LOCAL_MULTILIB == both 45LOCAL_NO_2ND_ARCH_MODULE_SUFFIX := true 46endif 47 48# if TARGET_PREFER_32_BIT_EXECUTABLES is set, try to build 32-bit first 49ifdef TARGET_2ND_ARCH 50ifeq ($(TARGET_PREFER_32_BIT_EXECUTABLES),true) 51LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX) 52else 53LOCAL_2ND_ARCH_VAR_PREFIX := 54endif 55endif 56 57my_skip_non_preferred_arch := 58 59# check if preferred arch is supported 60include $(BUILD_SYSTEM)/module_arch_supported.mk 61ifeq ($(my_module_arch_supported),true) 62# first arch is supported 63include $(BUILD_SYSTEM)/executable_internal.mk 64ifneq ($(my_module_multilib),both) 65my_skip_non_preferred_arch := true 66endif 67endif 68 69# check if preferred arch was not supported or asked to build both 70ifndef my_skip_non_preferred_arch 71ifdef TARGET_2ND_ARCH 72 73# check if the non-preferred arch is the primary or secondary 74ifeq ($(TARGET_PREFER_32_BIT_EXECUTABLES),true) 75LOCAL_2ND_ARCH_VAR_PREFIX := 76else 77LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX) 78endif 79 80# check if non-preferred arch is supported 81include $(BUILD_SYSTEM)/module_arch_supported.mk 82ifeq ($(my_module_arch_supported),true) 83# non-preferred arch is supported 84LOCAL_BUILT_MODULE := 85LOCAL_INSTALLED_MODULE := 86LOCAL_INTERMEDIATE_TARGETS := 87include $(BUILD_SYSTEM)/executable_internal.mk 88endif 89endif # TARGET_2ND_ARCH 90endif # !my_skip_non_preferred_arch || LOCAL_MULTILIB 91LOCAL_2ND_ARCH_VAR_PREFIX := 92LOCAL_NO_2ND_ARCH_MODULE_SUFFIX := 93 94my_module_arch_supported := 95 96endif 97