Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 1 | # |
| 2 | # Copyright (C) 2011 The Android Open Source Project |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
| 16 | |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 17 | include art/build/Android.common_build.mk |
Brian Carlstrom | 51c2467 | 2013-07-11 16:00:56 -0700 | [diff] [blame] | 18 | |
Brian Carlstrom | fa50baa | 2013-08-02 01:00:27 -0700 | [diff] [blame] | 19 | ART_HOST_EXECUTABLES ?= |
| 20 | ART_TARGET_EXECUTABLES ?= |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 21 | |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 22 | ART_EXECUTABLES_CFLAGS := |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 23 | |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 24 | # $(1): executable ("d" will be appended for debug version) |
| 25 | # $(2): source |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 26 | # $(3): extra shared libraries |
| 27 | # $(4): extra include directories |
| 28 | # $(5): target or host |
| 29 | # $(6): ndebug or debug |
Colin Cross | d747543 | 2014-03-20 12:55:13 -0700 | [diff] [blame] | 30 | # $(7): value for LOCAL_MULTILIB (empty means default) |
Calin Juravle | 65e069d | 2015-06-08 10:35:24 +0100 | [diff] [blame] | 31 | # $(8): static or shared (empty means shared, applies only for host) |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 32 | define build-art-executable |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 33 | ifneq ($(5),target) |
| 34 | ifneq ($(5),host) |
| 35 | $$(error expected target or host for argument 5, received $(5)) |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 36 | endif |
| 37 | endif |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 38 | ifneq ($(6),ndebug) |
| 39 | ifneq ($(6),debug) |
| 40 | $$(error expected ndebug or debug for argument 6, received $(6)) |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 41 | endif |
| 42 | endif |
| 43 | |
| 44 | art_executable := $(1) |
| 45 | art_source := $(2) |
Calin Juravle | 65e069d | 2015-06-08 10:35:24 +0100 | [diff] [blame] | 46 | art_libraries := $(3) |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 47 | art_c_includes := $(4) |
| 48 | art_target_or_host := $(5) |
| 49 | art_ndebug_or_debug := $(6) |
Colin Cross | d747543 | 2014-03-20 12:55:13 -0700 | [diff] [blame] | 50 | art_multilib := $(7) |
Calin Juravle | 65e069d | 2015-06-08 10:35:24 +0100 | [diff] [blame] | 51 | art_static_or_shared := $(8) |
Igor Murashkin | 3774335 | 2014-11-13 14:38:00 -0800 | [diff] [blame] | 52 | art_out_binary_name := |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 53 | |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 54 | include $(CLEAR_VARS) |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 55 | LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION) |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 56 | LOCAL_MODULE_TAGS := optional |
Dmitriy Ivanov | e49a4f6 | 2014-10-20 14:11:00 -0700 | [diff] [blame] | 57 | LOCAL_SRC_FILES := $$(art_source) |
Igor Murashkin | 3774335 | 2014-11-13 14:38:00 -0800 | [diff] [blame] | 58 | LOCAL_C_INCLUDES += $(ART_C_INCLUDES) art/runtime art/cmdline $$(art_c_includes) |
Calin Juravle | 65e069d | 2015-06-08 10:35:24 +0100 | [diff] [blame] | 59 | |
| 60 | ifeq ($$(art_static_or_shared),static) |
| 61 | LOCAL_STATIC_LIBRARIES += $$(art_libraries) |
| 62 | else |
| 63 | LOCAL_SHARED_LIBRARIES += $$(art_libraries) |
| 64 | endif |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 65 | |
| 66 | ifeq ($$(art_ndebug_or_debug),ndebug) |
| 67 | LOCAL_MODULE := $$(art_executable) |
| 68 | else #debug |
| 69 | LOCAL_MODULE := $$(art_executable)d |
Elliott Hughes | 1d3f114 | 2011-09-13 12:00:00 -0700 | [diff] [blame] | 70 | endif |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 71 | |
Calin Juravle | 65e069d | 2015-06-08 10:35:24 +0100 | [diff] [blame] | 72 | ifeq ($$(art_static_or_shared),static) |
| 73 | LOCAL_MODULE := $(LOCAL_MODULE)s |
| 74 | endif |
| 75 | |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 76 | LOCAL_CFLAGS := $(ART_EXECUTABLES_CFLAGS) |
Dan Albert | 7ccf48e | 2014-12-10 15:50:45 -0800 | [diff] [blame] | 77 | # Mac OS linker doesn't understand --export-dynamic. |
Dmitriy Ivanov | 1d74e57 | 2014-10-14 12:18:10 -0700 | [diff] [blame] | 78 | ifneq ($$(HOST_OS)-$$(art_target_or_host),darwin-host) |
Dan Albert | 7ccf48e | 2014-12-10 15:50:45 -0800 | [diff] [blame] | 79 | LOCAL_LDFLAGS := -Wl,--export-dynamic |
Dmitriy Ivanov | 1d74e57 | 2014-10-14 12:18:10 -0700 | [diff] [blame] | 80 | endif |
| 81 | |
Brian Carlstrom | 8952189 | 2011-12-07 22:05:07 -0800 | [diff] [blame] | 82 | ifeq ($$(art_target_or_host),target) |
Roland Levillain | 12bd721 | 2015-06-04 17:50:27 +0100 | [diff] [blame] | 83 | $(call set-target-local-clang-vars) |
| 84 | $(call set-target-local-cflags-vars,$(6)) |
Dmitriy Ivanov | f57874d | 2014-10-07 13:43:23 -0700 | [diff] [blame] | 85 | LOCAL_SHARED_LIBRARIES += libdl |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 86 | else # host |
Ian Rogers | cd5d042 | 2013-05-17 15:54:01 -0700 | [diff] [blame] | 87 | LOCAL_CLANG := $(ART_HOST_CLANG) |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 88 | LOCAL_LDLIBS := $(ART_HOST_LDLIBS) |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 89 | LOCAL_CFLAGS += $(ART_HOST_CFLAGS) |
Roland Levillain | 12bd721 | 2015-06-04 17:50:27 +0100 | [diff] [blame] | 90 | LOCAL_ASFLAGS += $(ART_HOST_ASFLAGS) |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 91 | ifeq ($$(art_ndebug_or_debug),debug) |
Brian Carlstrom | 8692721 | 2011-09-15 11:31:11 -0700 | [diff] [blame] | 92 | LOCAL_CFLAGS += $(ART_HOST_DEBUG_CFLAGS) |
Elliott Hughes | 3b6baaa | 2011-10-14 19:13:56 -0700 | [diff] [blame] | 93 | else |
| 94 | LOCAL_CFLAGS += $(ART_HOST_NON_DEBUG_CFLAGS) |
Brian Carlstrom | 8692721 | 2011-09-15 11:31:11 -0700 | [diff] [blame] | 95 | endif |
Calin Juravle | 9b36914 | 2015-07-02 13:48:37 +0100 | [diff] [blame] | 96 | LOCAL_LDLIBS += -lpthread -ldl |
Calin Juravle | 65e069d | 2015-06-08 10:35:24 +0100 | [diff] [blame] | 97 | ifeq ($$(art_static_or_shared),static) |
| 98 | LOCAL_LDFLAGS += -static |
| 99 | # We need this because GC stress mode makes use of _Unwind_GetIP and _Unwind_Backtrace and |
| 100 | # the symbols are also defined in libgcc_eh.a(unwind-dw2.o) |
| 101 | # TODO: Having this is not ideal as it might obscure errors. Try to get rid of it. |
| 102 | LOCAL_LDFLAGS += -z muldefs |
Calin Juravle | 9b36914 | 2015-07-02 13:48:37 +0100 | [diff] [blame] | 103 | ifeq ($$(HOST_OS),linux) |
Yabin Cui | f6010ec | 2015-09-21 20:28:36 -0700 | [diff] [blame] | 104 | LOCAL_LDLIBS += -lrt -lncurses -ltinfo |
| 105 | endif |
| 106 | ifeq ($$(HOST_OS),darwin) |
| 107 | LOCAL_LDLIBS += -lncurses -ltinfo |
Calin Juravle | 9b36914 | 2015-07-02 13:48:37 +0100 | [diff] [blame] | 108 | endif |
Calin Juravle | 65e069d | 2015-06-08 10:35:24 +0100 | [diff] [blame] | 109 | endif |
Calin Juravle | 9b36914 | 2015-07-02 13:48:37 +0100 | [diff] [blame] | 110 | |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 111 | endif |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 112 | |
Calin Juravle | 65e069d | 2015-06-08 10:35:24 +0100 | [diff] [blame] | 113 | # If dynamically linked add libart by default. Statically linked executables |
| 114 | # needs to specify it in art_libraries to ensure proper ordering. |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 115 | ifeq ($$(art_ndebug_or_debug),ndebug) |
Calin Juravle | 65e069d | 2015-06-08 10:35:24 +0100 | [diff] [blame] | 116 | ifneq ($$(art_static_or_shared),static) |
| 117 | LOCAL_SHARED_LIBRARIES += libart |
| 118 | endif |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 119 | else # debug |
Calin Juravle | 65e069d | 2015-06-08 10:35:24 +0100 | [diff] [blame] | 120 | ifneq ($$(art_static_or_shared),static) |
| 121 | LOCAL_SHARED_LIBRARIES += libartd |
| 122 | endif |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 123 | endif |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 124 | |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 125 | LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_build.mk |
Igor Murashkin | 3774335 | 2014-11-13 14:38:00 -0800 | [diff] [blame] | 126 | LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.common_utils.mk |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 127 | LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.executable.mk |
Brian Carlstrom | fa42b44 | 2013-06-17 12:53:45 -0700 | [diff] [blame] | 128 | |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 129 | ifeq ($$(art_target_or_host),target) |
Colin Cross | dc781a1 | 2014-02-04 16:22:03 -0800 | [diff] [blame] | 130 | LOCAL_MODULE_TARGET_ARCH := $(ART_SUPPORTED_ARCH) |
| 131 | endif |
Andreas Gampe | 088b16e | 2014-12-03 21:59:27 -0800 | [diff] [blame] | 132 | |
Ying Wang | 754a445 | 2015-07-21 12:05:30 -0700 | [diff] [blame] | 133 | ifdef ART_MULTILIB_OVERRIDE_$$(art_target_or_host) |
| 134 | art_multilib := $$(ART_MULTILIB_OVERRIDE_$$(art_target_or_host)) |
| 135 | endif |
| 136 | |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 137 | LOCAL_MULTILIB := $$(art_multilib) |
Igor Murashkin | 3774335 | 2014-11-13 14:38:00 -0800 | [diff] [blame] | 138 | art_out_binary_name := $$(LOCAL_MODULE) |
| 139 | |
| 140 | # If multilib=both (potentially building both 32-bit and 64-bit), need to provide stem. |
Andreas Gampe | 088b16e | 2014-12-03 21:59:27 -0800 | [diff] [blame] | 141 | ifeq ($$(art_multilib),both) |
Igor Murashkin | 3774335 | 2014-11-13 14:38:00 -0800 | [diff] [blame] | 142 | # Set up a 32-bit/64-bit stem if we are building both binaries. |
| 143 | # In this case, the 32-bit binary has an additional 32-bit suffix. |
| 144 | LOCAL_MODULE_STEM_32 := $$(LOCAL_MODULE)32 |
| 145 | LOCAL_MODULE_STEM_64 := $$(LOCAL_MODULE) |
| 146 | |
| 147 | # Remember the binary names so we can add them to the global art executables list later. |
| 148 | art_out_binary_name := $$(LOCAL_MODULE_STEM_32) $$(LOCAL_MODULE_STEM_64) |
| 149 | |
| 150 | # For single-architecture targets, remove any binary name suffixes. |
| 151 | ifeq ($$(art_target_or_host),target) |
| 152 | ifeq (,$(TARGET_2ND_ARCH)) |
| 153 | LOCAL_MODULE_STEM_32 := $$(LOCAL_MODULE) |
| 154 | art_out_binary_name := $$(LOCAL_MODULE) |
| 155 | endif |
| 156 | endif |
| 157 | |
| 158 | # For single-architecture hosts, remove any binary name suffixes. |
| 159 | ifeq ($$(art_target_or_host),host) |
| 160 | ifeq (,$(HOST_2ND_ARCH)) |
| 161 | LOCAL_MODULE_STEM_32 := $$(LOCAL_MODULE) |
| 162 | art_out_binary_name := $$(LOCAL_MODULE) |
| 163 | endif |
Andreas Gampe | 088b16e | 2014-12-03 21:59:27 -0800 | [diff] [blame] | 164 | endif |
| 165 | endif |
Colin Cross | dc781a1 | 2014-02-04 16:22:03 -0800 | [diff] [blame] | 166 | |
Dan Albert | 31fb260 | 2014-09-30 22:10:10 -0700 | [diff] [blame] | 167 | LOCAL_NATIVE_COVERAGE := $(ART_COVERAGE) |
| 168 | |
Colin Cross | dc781a1 | 2014-02-04 16:22:03 -0800 | [diff] [blame] | 169 | ifeq ($$(art_target_or_host),target) |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 170 | include $(BUILD_EXECUTABLE) |
Igor Murashkin | 3774335 | 2014-11-13 14:38:00 -0800 | [diff] [blame] | 171 | ART_TARGET_EXECUTABLES := $(ART_TARGET_EXECUTABLES) $$(foreach name,$$(art_out_binary_name),$(TARGET_OUT_EXECUTABLES)/$$(name)) |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 172 | else # host |
Ian Rogers | bd5ea6a | 2014-04-16 16:34:44 -0700 | [diff] [blame] | 173 | LOCAL_IS_HOST_MODULE := true |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 174 | include $(BUILD_HOST_EXECUTABLE) |
Igor Murashkin | 3774335 | 2014-11-13 14:38:00 -0800 | [diff] [blame] | 175 | ART_HOST_EXECUTABLES := $(ART_HOST_EXECUTABLES) $$(foreach name,$$(art_out_binary_name),$(HOST_OUT_EXECUTABLES)/$$(name)) |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 176 | endif |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 177 | |
Igor Murashkin | 3774335 | 2014-11-13 14:38:00 -0800 | [diff] [blame] | 178 | # Clear out local variables now that we're done with them. |
| 179 | art_executable := |
| 180 | art_source := |
Calin Juravle | 65e069d | 2015-06-08 10:35:24 +0100 | [diff] [blame] | 181 | art_libraries := |
Igor Murashkin | 3774335 | 2014-11-13 14:38:00 -0800 | [diff] [blame] | 182 | art_c_includes := |
| 183 | art_target_or_host := |
| 184 | art_ndebug_or_debug := |
| 185 | art_multilib := |
Calin Juravle | 65e069d | 2015-06-08 10:35:24 +0100 | [diff] [blame] | 186 | art_static_or_shared := |
Igor Murashkin | 3774335 | 2014-11-13 14:38:00 -0800 | [diff] [blame] | 187 | art_out_binary_name := |
| 188 | |
| 189 | endef |
| 190 | |
| 191 | # |
| 192 | # Build many art executables from multiple variations (debug/ndebug, host/target, 32/64bit). |
| 193 | # By default only either 32-bit or 64-bit is built (but not both -- see multilib arg). |
| 194 | # All other variations are gated by ANDROID_BUILD_(TARGET|HOST)_[N]DEBUG. |
| 195 | # The result must be eval-uated. |
| 196 | # |
| 197 | # $(1): executable name |
| 198 | # $(2): source files |
| 199 | # $(3): library dependencies (common); debug prefix is added on as necessary automatically. |
| 200 | # $(4): library dependencies (target only) |
| 201 | # $(5): library dependencies (host only) |
| 202 | # $(6): extra include directories |
| 203 | # $(7): multilib (default: empty), valid values: {,32,64,both}) |
Roland Levillain | 3045cfe | 2015-12-10 10:17:43 +0000 | [diff] [blame^] | 204 | # $(8): host prefer 32-bit: {true, false} (default: false). If argument |
| 205 | # `multilib` is explicitly set to 64, ignore the "host prefer 32-bit" |
| 206 | # setting and only build a 64-bit executable on host. |
Igor Murashkin | 3774335 | 2014-11-13 14:38:00 -0800 | [diff] [blame] | 207 | define build-art-multi-executable |
| 208 | $(foreach debug_flavor,ndebug debug, |
| 209 | $(foreach target_flavor,host target, |
| 210 | art-multi-binary-name := $(1) |
| 211 | art-multi-source-files := $(2) |
| 212 | art-multi-lib-dependencies := $(3) |
| 213 | art-multi-lib-dependencies-target := $(4) |
| 214 | art-multi-lib-dependencies-host := $(5) |
| 215 | art-multi-include-extra := $(6) |
| 216 | art-multi-multilib := $(7) |
Roland Levillain | 3045cfe | 2015-12-10 10:17:43 +0000 | [diff] [blame^] | 217 | art-multi-host-prefer-32-bit := $(8) |
Igor Murashkin | 3774335 | 2014-11-13 14:38:00 -0800 | [diff] [blame] | 218 | |
| 219 | # Add either -host or -target specific lib dependencies to the lib dependencies. |
| 220 | art-multi-lib-dependencies += $$(art-multi-lib-dependencies-$(target_flavor)) |
| 221 | |
| 222 | # Replace libart- prefix with libartd- for debug flavor. |
| 223 | ifeq ($(debug_flavor),debug) |
| 224 | art-multi-lib-dependencies := $$(subst libart-,libartd-,$$(art-multi-lib-dependencies)) |
| 225 | endif |
| 226 | |
| 227 | # Build the env guard var name, e.g. ART_BUILD_HOST_NDEBUG. |
| 228 | art-multi-env-guard := $$(call art-string-to-uppercase,ART_BUILD_$(target_flavor)_$(debug_flavor)) |
| 229 | |
Roland Levillain | 3045cfe | 2015-12-10 10:17:43 +0000 | [diff] [blame^] | 230 | ifeq ($(target_flavor),host) |
| 231 | ifeq ($$($$(art-multi-host-prefer-32-bit)),true) |
| 232 | ifneq ($$($$(art-multi-multilib)),64) |
| 233 | art-multi-multilib := 32 |
| 234 | endif |
| 235 | endif |
| 236 | endif |
| 237 | |
Igor Murashkin | 3774335 | 2014-11-13 14:38:00 -0800 | [diff] [blame] | 238 | # Build the art executable only if the corresponding env guard was set. |
| 239 | ifeq ($$($$(art-multi-env-guard)),true) |
| 240 | $$(eval $$(call build-art-executable,$$(art-multi-binary-name),$$(art-multi-source-files),$$(art-multi-lib-dependencies),$$(art-multi-include-extra),$(target_flavor),$(debug_flavor),$$(art-multi-multilib))) |
| 241 | endif |
| 242 | |
| 243 | # Clear locals now they've served their purpose. |
| 244 | art-multi-binary-name := |
| 245 | art-multi-source-files := |
| 246 | art-multi-lib-dependencies := |
| 247 | art-multi-lib-dependencies-target := |
| 248 | art-multi-lib-dependencies-host := |
| 249 | art-multi-include-extra := |
| 250 | art-multi-multilib := |
Roland Levillain | 3045cfe | 2015-12-10 10:17:43 +0000 | [diff] [blame^] | 251 | art-multi-host-prefer-32-bit := |
Igor Murashkin | 3774335 | 2014-11-13 14:38:00 -0800 | [diff] [blame] | 252 | art-multi-env-guard := |
| 253 | ) |
| 254 | ) |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 255 | endef |