• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
9ifdef LOCAL_IS_HOST_MODULE
10  $(call pretty-error,BUILD_EXECUTABLE is incompatible with LOCAL_IS_HOST_MODULE. Use BUILD_HOST_EXECUTABLE instead.)
11endif
12
13my_skip_this_target :=
14ifneq ($(filter address,$(SANITIZE_TARGET)),)
15  ifeq (true,$(LOCAL_FORCE_STATIC_EXECUTABLE))
16    my_skip_this_target := true
17  else ifeq (false, $(LOCAL_CLANG))
18    my_skip_this_target := true
19  else ifeq (never, $(LOCAL_SANITIZE))
20    my_skip_this_target := true
21  endif
22endif
23
24ifneq (true,$(my_skip_this_target))
25$(call record-module-type,EXECUTABLE)
26
27my_prefix := TARGET_
28include $(BUILD_SYSTEM)/multilib.mk
29
30ifeq ($(my_module_multilib),both)
31ifneq ($(LOCAL_MODULE_CLASS),NATIVE_TESTS)
32ifeq ($(LOCAL_MODULE_PATH_32)$(LOCAL_MODULE_STEM_32),)
33$(error $(LOCAL_PATH): LOCAL_MODULE_STEM_32 or LOCAL_MODULE_PATH_32 is required for LOCAL_MULTILIB := both for module $(LOCAL_MODULE))
34endif
35ifeq ($(LOCAL_MODULE_PATH_64)$(LOCAL_MODULE_STEM_64),)
36$(error $(LOCAL_PATH): LOCAL_MODULE_STEM_64 or LOCAL_MODULE_PATH_64 is required for LOCAL_MULTILIB := both for module $(LOCAL_MODULE))
37endif
38endif
39else #!LOCAL_MULTILIB == both
40LOCAL_NO_2ND_ARCH_MODULE_SUFFIX := true
41endif
42
43# if TARGET_PREFER_32_BIT_EXECUTABLES is set, try to build 32-bit first
44ifdef TARGET_2ND_ARCH
45ifeq ($(TARGET_PREFER_32_BIT_EXECUTABLES),true)
46LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX)
47else
48LOCAL_2ND_ARCH_VAR_PREFIX :=
49endif
50endif
51
52my_skip_non_preferred_arch :=
53
54# check if preferred arch is supported
55include $(BUILD_SYSTEM)/module_arch_supported.mk
56ifeq ($(my_module_arch_supported),true)
57# first arch is supported
58include $(BUILD_SYSTEM)/executable_internal.mk
59ifneq ($(my_module_multilib),both)
60my_skip_non_preferred_arch := true
61endif
62endif
63
64# check if preferred arch was not supported or asked to build both
65ifndef my_skip_non_preferred_arch
66ifdef TARGET_2ND_ARCH
67
68# check if the non-preferred arch is the primary or secondary
69ifeq ($(TARGET_PREFER_32_BIT_EXECUTABLES),true)
70LOCAL_2ND_ARCH_VAR_PREFIX :=
71else
72LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX)
73endif
74
75# check if non-preferred arch is supported
76include $(BUILD_SYSTEM)/module_arch_supported.mk
77ifeq ($(my_module_arch_supported),true)
78# non-preferred arch is supported
79LOCAL_BUILT_MODULE :=
80LOCAL_INSTALLED_MODULE :=
81LOCAL_INTERMEDIATE_TARGETS :=
82include $(BUILD_SYSTEM)/executable_internal.mk
83endif
84endif # TARGET_2ND_ARCH
85endif # !my_skip_non_preferred_arch || LOCAL_MULTILIB
86LOCAL_2ND_ARCH_VAR_PREFIX :=
87LOCAL_NO_2ND_ARCH_MODULE_SUFFIX :=
88
89my_module_arch_supported :=
90
91endif
92