blob: f1b2462e46c5e8971ffe9ebd89bab6f7fe911efe [file] [log] [blame]
Ying Wangdd814bf2014-01-17 16:17:28 -08001# 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.
Colin Crosse6e48f62014-03-21 12:29:32 -07004# 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
Evgenii Stepanov3632cc32015-06-11 13:57:10 -07009my_skip_this_target :=
Ivan Krasin74b32b82015-09-18 11:54:43 -070010ifneq ($(filter address,$(SANITIZE_TARGET)),)
Evgenii Stepanov3632cc32015-06-11 13:57:10 -070011 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))
Dan Willemsen1684b322016-07-25 16:03:53 -070019$(call record-module-type,EXECUTABLE)
Evgenii Stepanov3632cc32015-06-11 13:57:10 -070020
Ying Wang87538e42016-03-16 19:53:19 -070021ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
Ying Wang62630222016-04-20 11:53:39 -070022# 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)))
Ying Wang87538e42016-03-16 19:53:19 -070026LOCAL_MULTILIB := first
27endif
Ying Wang62630222016-04-20 11:53:39 -070028endif
Ying Wang87538e42016-03-16 19:53:19 -070029
Ying Wang6feb6d52014-04-17 10:03:35 -070030my_prefix := TARGET_
Colin Crosse6e48f62014-03-21 12:29:32 -070031include $(BUILD_SYSTEM)/multilib.mk
The Android Open Source Project88b60792009-03-03 19:28:42 -080032
Colin Crosse6e48f62014-03-21 12:29:32 -070033ifeq ($(my_module_multilib),both)
Dan Willemsen7fe992c2016-03-02 13:54:51 -080034ifneq ($(LOCAL_MODULE_CLASS),NATIVE_TESTS)
Colin Crosse6e48f62014-03-21 12:29:32 -070035ifeq ($(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
Dan Willemsen7fe992c2016-03-02 13:54:51 -080041endif
Colin Crosse6e48f62014-03-21 12:29:32 -070042else #!LOCAL_MULTILIB == both
Colin Crossaee1e772014-02-04 11:16:16 -080043LOCAL_NO_2ND_ARCH_MODULE_SUFFIX := true
Colin Crosse6e48f62014-03-21 12:29:32 -070044endif
Colin Cross8e404122014-02-06 14:45:37 -080045
Colin Crossa3339e92014-04-30 18:09:13 -070046# if TARGET_PREFER_32_BIT_EXECUTABLES is set, try to build 32-bit first
Colin Crossd3624d52014-04-10 12:28:56 -070047ifdef TARGET_2ND_ARCH
Colin Crossa3339e92014-04-30 18:09:13 -070048ifeq ($(TARGET_PREFER_32_BIT_EXECUTABLES),true)
Colin Crossd3624d52014-04-10 12:28:56 -070049LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX)
50else
51LOCAL_2ND_ARCH_VAR_PREFIX :=
52endif
53endif
Colin Crosse6e48f62014-03-21 12:29:32 -070054
Colin Crossd3624d52014-04-10 12:28:56 -070055my_skip_non_preferred_arch :=
56
57# check if preferred arch is supported
Colin Cross8e404122014-02-06 14:45:37 -080058include $(BUILD_SYSTEM)/module_arch_supported.mk
59ifeq ($(my_module_arch_supported),true)
Colin Crosse6e48f62014-03-21 12:29:32 -070060# first arch is supported
Ying Wangdd814bf2014-01-17 16:17:28 -080061include $(BUILD_SYSTEM)/executable_internal.mk
Colin Crosse6e48f62014-03-21 12:29:32 -070062ifneq ($(my_module_multilib),both)
Colin Crossd3624d52014-04-10 12:28:56 -070063my_skip_non_preferred_arch := true
Colin Crosse6e48f62014-03-21 12:29:32 -070064endif
65endif
66
Colin Crossd3624d52014-04-10 12:28:56 -070067# check if preferred arch was not supported or asked to build both
68ifndef my_skip_non_preferred_arch
Colin Crosse6e48f62014-03-21 12:29:32 -070069ifdef TARGET_2ND_ARCH
Colin Crossd3624d52014-04-10 12:28:56 -070070
71# check if the non-preferred arch is the primary or secondary
Colin Crossa3339e92014-04-30 18:09:13 -070072ifeq ($(TARGET_PREFER_32_BIT_EXECUTABLES),true)
Colin Crossd3624d52014-04-10 12:28:56 -070073LOCAL_2ND_ARCH_VAR_PREFIX :=
74else
Colin Cross8e404122014-02-06 14:45:37 -080075LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX)
Colin Crossd3624d52014-04-10 12:28:56 -070076endif
77
78# check if non-preferred arch is supported
Colin Cross8e404122014-02-06 14:45:37 -080079include $(BUILD_SYSTEM)/module_arch_supported.mk
80ifeq ($(my_module_arch_supported),true)
Colin Crossd3624d52014-04-10 12:28:56 -070081# non-preferred arch is supported
Colin Crosse6e48f62014-03-21 12:29:32 -070082OVERRIDE_BUILT_MODULE_PATH :=
83LOCAL_BUILT_MODULE :=
84LOCAL_INSTALLED_MODULE :=
Colin Crosse6e48f62014-03-21 12:29:32 -070085LOCAL_INTERMEDIATE_TARGETS :=
Colin Cross8e404122014-02-06 14:45:37 -080086include $(BUILD_SYSTEM)/executable_internal.mk
87endif
88endif # TARGET_2ND_ARCH
Colin Crossd3624d52014-04-10 12:28:56 -070089endif # !my_skip_non_preferred_arch || LOCAL_MULTILIB
Ying Wangdd814bf2014-01-17 16:17:28 -080090LOCAL_2ND_ARCH_VAR_PREFIX :=
Colin Crossaee1e772014-02-04 11:16:16 -080091LOCAL_NO_2ND_ARCH_MODULE_SUFFIX :=
Colin Cross8e404122014-02-06 14:45:37 -080092
93my_module_arch_supported :=
Evgenii Stepanov3632cc32015-06-11 13:57:10 -070094
95endif