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) |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 31 | define build-art-executable |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 32 | ifneq ($(5),target) |
| 33 | ifneq ($(5),host) |
| 34 | $$(error expected target or host for argument 5, received $(5)) |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 35 | endif |
| 36 | endif |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 37 | ifneq ($(6),ndebug) |
| 38 | ifneq ($(6),debug) |
| 39 | $$(error expected ndebug or debug for argument 6, received $(6)) |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 40 | endif |
| 41 | endif |
| 42 | |
| 43 | art_executable := $(1) |
| 44 | art_source := $(2) |
Brian Carlstrom | 51c2467 | 2013-07-11 16:00:56 -0700 | [diff] [blame] | 45 | art_shared_libraries := $(3) |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 46 | art_c_includes := $(4) |
| 47 | art_target_or_host := $(5) |
| 48 | art_ndebug_or_debug := $(6) |
Colin Cross | d747543 | 2014-03-20 12:55:13 -0700 | [diff] [blame] | 49 | art_multilib := $(7) |
Igor Murashkin | 3774335 | 2014-11-13 14:38:00 -0800 | [diff] [blame] | 50 | art_out_binary_name := |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 51 | |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 52 | include $(CLEAR_VARS) |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 53 | LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION) |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 54 | LOCAL_MODULE_TAGS := optional |
Dmitriy Ivanov | e49a4f6 | 2014-10-20 14:11:00 -0700 | [diff] [blame] | 55 | LOCAL_SRC_FILES := $$(art_source) |
Igor Murashkin | 3774335 | 2014-11-13 14:38:00 -0800 | [diff] [blame] | 56 | LOCAL_C_INCLUDES += $(ART_C_INCLUDES) art/runtime art/cmdline $$(art_c_includes) |
Ian Rogers | ba0c51f | 2014-05-16 12:26:00 -0700 | [diff] [blame] | 57 | LOCAL_SHARED_LIBRARIES += $$(art_shared_libraries) |
Dmitriy Ivanov | e49a4f6 | 2014-10-20 14:11:00 -0700 | [diff] [blame] | 58 | LOCAL_WHOLE_STATIC_LIBRARIES += libsigchain |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 59 | |
| 60 | ifeq ($$(art_ndebug_or_debug),ndebug) |
| 61 | LOCAL_MODULE := $$(art_executable) |
| 62 | else #debug |
| 63 | LOCAL_MODULE := $$(art_executable)d |
Elliott Hughes | 1d3f114 | 2011-09-13 12:00:00 -0700 | [diff] [blame] | 64 | endif |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 65 | |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 66 | LOCAL_CFLAGS := $(ART_EXECUTABLES_CFLAGS) |
Dan Albert | 7ccf48e | 2014-12-10 15:50:45 -0800 | [diff] [blame] | 67 | # Mac OS linker doesn't understand --export-dynamic. |
Dmitriy Ivanov | 1d74e57 | 2014-10-14 12:18:10 -0700 | [diff] [blame] | 68 | ifneq ($$(HOST_OS)-$$(art_target_or_host),darwin-host) |
Dan Albert | 7ccf48e | 2014-12-10 15:50:45 -0800 | [diff] [blame] | 69 | LOCAL_LDFLAGS := -Wl,--export-dynamic |
Dmitriy Ivanov | 1d74e57 | 2014-10-14 12:18:10 -0700 | [diff] [blame] | 70 | endif |
| 71 | |
Brian Carlstrom | 8952189 | 2011-12-07 22:05:07 -0800 | [diff] [blame] | 72 | ifeq ($$(art_target_or_host),target) |
Andreas Gampe | 5ca4eaa | 2014-05-29 02:09:33 -0700 | [diff] [blame] | 73 | $(call set-target-local-clang-vars) |
| 74 | $(call set-target-local-cflags-vars,$(6)) |
Dmitriy Ivanov | f57874d | 2014-10-07 13:43:23 -0700 | [diff] [blame] | 75 | LOCAL_SHARED_LIBRARIES += libdl |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 76 | else # host |
Ian Rogers | cd5d042 | 2013-05-17 15:54:01 -0700 | [diff] [blame] | 77 | LOCAL_CLANG := $(ART_HOST_CLANG) |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 78 | LOCAL_LDLIBS := $(ART_HOST_LDLIBS) |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 79 | LOCAL_CFLAGS += $(ART_HOST_CFLAGS) |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 80 | ifeq ($$(art_ndebug_or_debug),debug) |
Brian Carlstrom | 8692721 | 2011-09-15 11:31:11 -0700 | [diff] [blame] | 81 | LOCAL_CFLAGS += $(ART_HOST_DEBUG_CFLAGS) |
Elliott Hughes | 3b6baaa | 2011-10-14 19:13:56 -0700 | [diff] [blame] | 82 | else |
| 83 | LOCAL_CFLAGS += $(ART_HOST_NON_DEBUG_CFLAGS) |
Brian Carlstrom | 8692721 | 2011-09-15 11:31:11 -0700 | [diff] [blame] | 84 | endif |
Dmitriy Ivanov | f57874d | 2014-10-07 13:43:23 -0700 | [diff] [blame] | 85 | LOCAL_LDLIBS += -lpthread -ldl |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 86 | endif |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 87 | |
| 88 | ifeq ($$(art_ndebug_or_debug),ndebug) |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 89 | LOCAL_SHARED_LIBRARIES += libart |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 90 | else # debug |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 91 | LOCAL_SHARED_LIBRARIES += libartd |
| 92 | endif |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 93 | |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 94 | LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_build.mk |
Igor Murashkin | 3774335 | 2014-11-13 14:38:00 -0800 | [diff] [blame] | 95 | LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.common_utils.mk |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 96 | LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.executable.mk |
Brian Carlstrom | fa42b44 | 2013-06-17 12:53:45 -0700 | [diff] [blame] | 97 | |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 98 | ifeq ($$(art_target_or_host),target) |
Colin Cross | dc781a1 | 2014-02-04 16:22:03 -0800 | [diff] [blame] | 99 | LOCAL_MODULE_TARGET_ARCH := $(ART_SUPPORTED_ARCH) |
| 100 | endif |
Andreas Gampe | 088b16e | 2014-12-03 21:59:27 -0800 | [diff] [blame] | 101 | |
Ian Rogers | afd9acc | 2014-06-17 08:21:54 -0700 | [diff] [blame] | 102 | LOCAL_MULTILIB := $$(art_multilib) |
Igor Murashkin | 3774335 | 2014-11-13 14:38:00 -0800 | [diff] [blame] | 103 | art_out_binary_name := $$(LOCAL_MODULE) |
| 104 | |
| 105 | # 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] | 106 | ifeq ($$(art_multilib),both) |
Igor Murashkin | 3774335 | 2014-11-13 14:38:00 -0800 | [diff] [blame] | 107 | # Set up a 32-bit/64-bit stem if we are building both binaries. |
| 108 | # In this case, the 32-bit binary has an additional 32-bit suffix. |
| 109 | LOCAL_MODULE_STEM_32 := $$(LOCAL_MODULE)32 |
| 110 | LOCAL_MODULE_STEM_64 := $$(LOCAL_MODULE) |
| 111 | |
| 112 | # Remember the binary names so we can add them to the global art executables list later. |
| 113 | art_out_binary_name := $$(LOCAL_MODULE_STEM_32) $$(LOCAL_MODULE_STEM_64) |
| 114 | |
| 115 | # For single-architecture targets, remove any binary name suffixes. |
| 116 | ifeq ($$(art_target_or_host),target) |
| 117 | ifeq (,$(TARGET_2ND_ARCH)) |
| 118 | LOCAL_MODULE_STEM_32 := $$(LOCAL_MODULE) |
| 119 | art_out_binary_name := $$(LOCAL_MODULE) |
| 120 | endif |
| 121 | endif |
| 122 | |
| 123 | # For single-architecture hosts, remove any binary name suffixes. |
| 124 | ifeq ($$(art_target_or_host),host) |
| 125 | ifeq (,$(HOST_2ND_ARCH)) |
| 126 | LOCAL_MODULE_STEM_32 := $$(LOCAL_MODULE) |
| 127 | art_out_binary_name := $$(LOCAL_MODULE) |
| 128 | endif |
Andreas Gampe | 088b16e | 2014-12-03 21:59:27 -0800 | [diff] [blame] | 129 | endif |
| 130 | endif |
Colin Cross | dc781a1 | 2014-02-04 16:22:03 -0800 | [diff] [blame] | 131 | |
| 132 | ifeq ($$(art_target_or_host),target) |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 133 | include $(BUILD_EXECUTABLE) |
Igor Murashkin | 3774335 | 2014-11-13 14:38:00 -0800 | [diff] [blame] | 134 | 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] | 135 | else # host |
Ian Rogers | bd5ea6a | 2014-04-16 16:34:44 -0700 | [diff] [blame] | 136 | LOCAL_IS_HOST_MODULE := true |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 137 | include $(BUILD_HOST_EXECUTABLE) |
Igor Murashkin | 3774335 | 2014-11-13 14:38:00 -0800 | [diff] [blame] | 138 | 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] | 139 | endif |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 140 | |
Igor Murashkin | 3774335 | 2014-11-13 14:38:00 -0800 | [diff] [blame] | 141 | # Clear out local variables now that we're done with them. |
| 142 | art_executable := |
| 143 | art_source := |
| 144 | art_shared_libraries := |
| 145 | art_c_includes := |
| 146 | art_target_or_host := |
| 147 | art_ndebug_or_debug := |
| 148 | art_multilib := |
| 149 | art_out_binary_name := |
| 150 | |
| 151 | endef |
| 152 | |
| 153 | # |
| 154 | # Build many art executables from multiple variations (debug/ndebug, host/target, 32/64bit). |
| 155 | # By default only either 32-bit or 64-bit is built (but not both -- see multilib arg). |
| 156 | # All other variations are gated by ANDROID_BUILD_(TARGET|HOST)_[N]DEBUG. |
| 157 | # The result must be eval-uated. |
| 158 | # |
| 159 | # $(1): executable name |
| 160 | # $(2): source files |
| 161 | # $(3): library dependencies (common); debug prefix is added on as necessary automatically. |
| 162 | # $(4): library dependencies (target only) |
| 163 | # $(5): library dependencies (host only) |
| 164 | # $(6): extra include directories |
| 165 | # $(7): multilib (default: empty), valid values: {,32,64,both}) |
| 166 | define build-art-multi-executable |
| 167 | $(foreach debug_flavor,ndebug debug, |
| 168 | $(foreach target_flavor,host target, |
| 169 | art-multi-binary-name := $(1) |
| 170 | art-multi-source-files := $(2) |
| 171 | art-multi-lib-dependencies := $(3) |
| 172 | art-multi-lib-dependencies-target := $(4) |
| 173 | art-multi-lib-dependencies-host := $(5) |
| 174 | art-multi-include-extra := $(6) |
| 175 | art-multi-multilib := $(7) |
| 176 | |
| 177 | # Add either -host or -target specific lib dependencies to the lib dependencies. |
| 178 | art-multi-lib-dependencies += $$(art-multi-lib-dependencies-$(target_flavor)) |
| 179 | |
| 180 | # Replace libart- prefix with libartd- for debug flavor. |
| 181 | ifeq ($(debug_flavor),debug) |
| 182 | art-multi-lib-dependencies := $$(subst libart-,libartd-,$$(art-multi-lib-dependencies)) |
| 183 | endif |
| 184 | |
| 185 | # Build the env guard var name, e.g. ART_BUILD_HOST_NDEBUG. |
| 186 | art-multi-env-guard := $$(call art-string-to-uppercase,ART_BUILD_$(target_flavor)_$(debug_flavor)) |
| 187 | |
| 188 | # Build the art executable only if the corresponding env guard was set. |
| 189 | ifeq ($$($$(art-multi-env-guard)),true) |
| 190 | $$(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))) |
| 191 | endif |
| 192 | |
| 193 | # Clear locals now they've served their purpose. |
| 194 | art-multi-binary-name := |
| 195 | art-multi-source-files := |
| 196 | art-multi-lib-dependencies := |
| 197 | art-multi-lib-dependencies-target := |
| 198 | art-multi-lib-dependencies-host := |
| 199 | art-multi-include-extra := |
| 200 | art-multi-multilib := |
| 201 | art-multi-env-guard := |
| 202 | ) |
| 203 | ) |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 204 | endef |