The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1 | # |
| 2 | # Copyright (C) 2008 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 | |
| 17 | # Users can define base-rules-hook in their buildspec.mk to perform |
| 18 | # arbitrary operations as each module is included. |
| 19 | ifdef base-rules-hook |
| 20 | $(if $(base-rules-hook),) |
| 21 | endif |
| 22 | |
| 23 | ########################################################### |
| 24 | ## Common instructions for a generic module. |
| 25 | ########################################################### |
| 26 | |
| 27 | LOCAL_MODULE := $(strip $(LOCAL_MODULE)) |
| 28 | ifeq ($(LOCAL_MODULE),) |
| 29 | $(error $(LOCAL_PATH): LOCAL_MODULE is not defined) |
| 30 | endif |
| 31 | |
| 32 | LOCAL_IS_HOST_MODULE := $(strip $(LOCAL_IS_HOST_MODULE)) |
| 33 | ifdef LOCAL_IS_HOST_MODULE |
| 34 | ifneq ($(LOCAL_IS_HOST_MODULE),true) |
| 35 | $(error $(LOCAL_PATH): LOCAL_IS_HOST_MODULE must be "true" or empty, not "$(LOCAL_IS_HOST_MODULE)") |
| 36 | endif |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 37 | ifeq ($(LOCAL_HOST_PREFIX),) |
| 38 | my_prefix := HOST_ |
| 39 | else |
| 40 | my_prefix := $(LOCAL_HOST_PREFIX) |
| 41 | endif |
Ying Wang | 13d6950 | 2012-11-01 17:22:33 -0700 | [diff] [blame] | 42 | my_host := host- |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 43 | else |
Ying Wang | 13d6950 | 2012-11-01 17:22:33 -0700 | [diff] [blame] | 44 | my_prefix := TARGET_ |
| 45 | my_host := |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 46 | endif |
| 47 | |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 48 | ifeq ($(my_prefix),HOST_CROSS_) |
| 49 | my_host_cross := true |
| 50 | else |
| 51 | my_host_cross := |
| 52 | endif |
| 53 | |
Ying Wang | 37bd1f2 | 2014-01-27 15:19:09 -0800 | [diff] [blame] | 54 | my_module_tags := $(LOCAL_MODULE_TAGS) |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 55 | ifeq ($(my_host_cross),true) |
| 56 | my_module_tags := |
| 57 | endif |
Ying Wang | 37bd1f2 | 2014-01-27 15:19:09 -0800 | [diff] [blame] | 58 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 59 | ########################################################### |
| 60 | ## Validate and define fallbacks for input LOCAL_* variables. |
| 61 | ########################################################### |
| 62 | |
| 63 | ## Dump a .csv file of all modules and their tags |
| 64 | #ifneq ($(tag-list-first-time),false) |
| 65 | #$(shell rm -f tag-list.csv) |
| 66 | #tag-list-first-time := false |
| 67 | #endif |
Ying Wang | 37bd1f2 | 2014-01-27 15:19:09 -0800 | [diff] [blame] | 68 | #$(shell echo $(lastword $(filter-out config/% out/%,$(MAKEFILE_LIST))),$(LOCAL_MODULE),$(strip $(LOCAL_MODULE_CLASS)),$(subst $(space),$(comma),$(sort $(my_module_tags))) >> tag-list.csv) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 69 | |
Ying Wang | 6e371e4 | 2012-05-15 14:31:26 -0700 | [diff] [blame] | 70 | LOCAL_UNINSTALLABLE_MODULE := $(strip $(LOCAL_UNINSTALLABLE_MODULE)) |
Ying Wang | 37bd1f2 | 2014-01-27 15:19:09 -0800 | [diff] [blame] | 71 | my_module_tags := $(sort $(my_module_tags)) |
| 72 | ifeq (,$(my_module_tags)) |
| 73 | my_module_tags := optional |
Ying Wang | 2fd81cf | 2010-12-10 11:17:28 -0800 | [diff] [blame] | 74 | endif |
Joe Onorato | 918ee31 | 2012-05-18 20:43:14 -0700 | [diff] [blame] | 75 | |
Joe Onorato | 6a185e4 | 2012-05-22 14:08:50 -0700 | [diff] [blame] | 76 | # User tags are not allowed anymore. Fail early because it will not be installed |
| 77 | # like it used to be. |
Ying Wang | 37bd1f2 | 2014-01-27 15:19:09 -0800 | [diff] [blame] | 78 | ifneq ($(filter $(my_module_tags),user),) |
Joe Onorato | 6a185e4 | 2012-05-22 14:08:50 -0700 | [diff] [blame] | 79 | $(warning *** Module name: $(LOCAL_MODULE)) |
| 80 | $(warning *** Makefile location: $(LOCAL_MODULE_MAKEFILE)) |
| 81 | $(warning * ) |
| 82 | $(warning * Module is attempting to use the 'user' tag. This) |
| 83 | $(warning * used to cause the module to be installed automatically.) |
| 84 | $(warning * Now, the module must be listed in the PRODUCT_PACKAGES) |
| 85 | $(warning * section of a product makefile to have it installed.) |
| 86 | $(warning * ) |
| 87 | $(error user tag detected on module.) |
| 88 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 89 | |
Jean-Baptiste Queru | a831cbd | 2010-01-07 11:06:50 -0800 | [diff] [blame] | 90 | # Only the tags mentioned in this test are expected to be set by module |
| 91 | # makefiles. Anything else is either a typo or a source of unexpected |
| 92 | # behaviors. |
Ying Wang | 37bd1f2 | 2014-01-27 15:19:09 -0800 | [diff] [blame] | 93 | ifneq ($(filter-out debug eng tests optional samples,$(my_module_tags)),) |
| 94 | $(warning unusual tags $(my_module_tags) on $(LOCAL_MODULE) at $(LOCAL_PATH)) |
Jean-Baptiste Queru | a831cbd | 2010-01-07 11:06:50 -0800 | [diff] [blame] | 95 | endif |
| 96 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 97 | # Add implicit tags. |
| 98 | # |
| 99 | # If the local directory or one of its parents contains a MODULE_LICENSE_GPL |
Andrew Boie | 08a943b | 2013-12-10 13:52:00 -0800 | [diff] [blame] | 100 | # file, tag the module as "gnu". Search for "*_GPL*", "*_LGPL*" and "*_MPL*" |
| 101 | # so that we can also find files like MODULE_LICENSE_GPL_AND_AFL |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 102 | # |
Ying Wang | 39b9b69 | 2015-05-07 12:08:53 -0700 | [diff] [blame] | 103 | license_files := $(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*) |
Andrew Boie | 08a943b | 2013-12-10 13:52:00 -0800 | [diff] [blame] | 104 | gpl_license_file := $(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*_GPL* MODULE_LICENSE*_MPL* MODULE_LICENSE*_LGPL*) |
Ying Wang | fd626f2 | 2011-12-12 12:57:38 -0800 | [diff] [blame] | 105 | ifneq ($(gpl_license_file),) |
Ying Wang | 37bd1f2 | 2014-01-27 15:19:09 -0800 | [diff] [blame] | 106 | my_module_tags += gnu |
Ying Wang | fd626f2 | 2011-12-12 12:57:38 -0800 | [diff] [blame] | 107 | ALL_GPL_MODULE_LICENSE_FILES := $(sort $(ALL_GPL_MODULE_LICENSE_FILES) $(gpl_license_file)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 108 | endif |
| 109 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 110 | LOCAL_MODULE_CLASS := $(strip $(LOCAL_MODULE_CLASS)) |
| 111 | ifneq ($(words $(LOCAL_MODULE_CLASS)),1) |
| 112 | $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS must contain exactly one word, not "$(LOCAL_MODULE_CLASS)") |
| 113 | endif |
| 114 | |
Ying Wang | 6feb6d5 | 2014-04-17 10:03:35 -0700 | [diff] [blame] | 115 | my_32_64_bit_suffix := $(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT),64,32) |
Colin Cross | 8797405 | 2014-03-21 12:25:44 -0700 | [diff] [blame] | 116 | |
Ying Wang | 6e371e4 | 2012-05-15 14:31:26 -0700 | [diff] [blame] | 117 | ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE)) |
Colin Cross | 8797405 | 2014-03-21 12:25:44 -0700 | [diff] [blame] | 118 | my_multilib_module_path := $(strip $(LOCAL_MODULE_PATH_$(my_32_64_bit_suffix))) |
Colin Cross | 8797405 | 2014-03-21 12:25:44 -0700 | [diff] [blame] | 119 | ifdef my_multilib_module_path |
| 120 | my_module_path := $(my_multilib_module_path) |
| 121 | else |
Ying Wang | b8e0185 | 2014-01-23 15:09:04 -0800 | [diff] [blame] | 122 | my_module_path := $(strip $(LOCAL_MODULE_PATH)) |
Colin Cross | 8797405 | 2014-03-21 12:25:44 -0700 | [diff] [blame] | 123 | endif |
Colin Cross | 639c336 | 2014-01-24 19:23:40 -0800 | [diff] [blame] | 124 | my_module_relative_path := $(strip $(LOCAL_MODULE_RELATIVE_PATH)) |
Ying Wang | b8e0185 | 2014-01-23 15:09:04 -0800 | [diff] [blame] | 125 | ifeq ($(my_module_path),) |
Ying Wang | 5338fbf | 2013-05-08 15:49:08 -0700 | [diff] [blame] | 126 | ifdef LOCAL_IS_HOST_MODULE |
| 127 | partition_tag := |
| 128 | else |
| 129 | ifeq (true,$(LOCAL_PROPRIETARY_MODULE)) |
| 130 | partition_tag := _VENDOR |
Ying Wang | b888843 | 2014-03-11 17:13:27 -0700 | [diff] [blame] | 131 | else ifeq (true,$(LOCAL_OEM_MODULE)) |
| 132 | partition_tag := _OEM |
Ying Wang | 4540a85 | 2015-03-12 18:30:39 -0700 | [diff] [blame] | 133 | else ifeq (true,$(LOCAL_ODM_MODULE)) |
| 134 | partition_tag := _ODM |
Ying Wang | 5338fbf | 2013-05-08 15:49:08 -0700 | [diff] [blame] | 135 | else |
| 136 | # The definition of should-install-to-system will be different depending |
| 137 | # on which goal (e.g., sdk or just droid) is being built. |
Ying Wang | 37bd1f2 | 2014-01-27 15:19:09 -0800 | [diff] [blame] | 138 | partition_tag := $(if $(call should-install-to-system,$(my_module_tags)),,_DATA) |
Ying Wang | 5338fbf | 2013-05-08 15:49:08 -0700 | [diff] [blame] | 139 | endif |
| 140 | endif |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 141 | install_path_var := $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT$(partition_tag)_$(LOCAL_MODULE_CLASS) |
Ying Wang | 5338fbf | 2013-05-08 15:49:08 -0700 | [diff] [blame] | 142 | ifeq (true,$(LOCAL_PRIVILEGED_MODULE)) |
| 143 | install_path_var := $(install_path_var)_PRIVILEGED |
| 144 | endif |
| 145 | |
Colin Cross | b34911c | 2014-01-22 17:34:28 -0800 | [diff] [blame] | 146 | my_module_path := $($(install_path_var)) |
Ying Wang | b8e0185 | 2014-01-23 15:09:04 -0800 | [diff] [blame] | 147 | ifeq ($(strip $(my_module_path)),) |
| 148 | $(error $(LOCAL_PATH): unhandled install path "$(install_path_var) for $(LOCAL_MODULE)") |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 149 | endif |
| 150 | endif |
Colin Cross | 639c336 | 2014-01-24 19:23:40 -0800 | [diff] [blame] | 151 | ifneq ($(my_module_relative_path),) |
| 152 | my_module_path := $(my_module_path)/$(my_module_relative_path) |
| 153 | endif |
Ying Wang | 6e371e4 | 2012-05-15 14:31:26 -0700 | [diff] [blame] | 154 | endif # not LOCAL_UNINSTALLABLE_MODULE |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 155 | |
| 156 | ifneq ($(strip $(LOCAL_BUILT_MODULE)$(LOCAL_INSTALLED_MODULE)),) |
| 157 | $(error $(LOCAL_PATH): LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE must not be defined by component makefiles) |
| 158 | endif |
| 159 | |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 160 | my_register_name := $(LOCAL_MODULE) |
| 161 | ifdef LOCAL_2ND_ARCH_VAR_PREFIX |
Colin Cross | aee1e77 | 2014-02-04 11:16:16 -0800 | [diff] [blame] | 162 | ifndef LOCAL_NO_2ND_ARCH_MODULE_SUFFIX |
Ying Wang | 6feb6d5 | 2014-04-17 10:03:35 -0700 | [diff] [blame] | 163 | my_register_name := $(LOCAL_MODULE)$($(my_prefix)2ND_ARCH_MODULE_SUFFIX) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 164 | endif |
Colin Cross | aee1e77 | 2014-02-04 11:16:16 -0800 | [diff] [blame] | 165 | endif |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 166 | ifeq ($(my_host_cross),true) |
| 167 | my_register_name := host_cross_$(LOCAL_MODULE) |
| 168 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 169 | # Make sure that this IS_HOST/CLASS/MODULE combination is unique. |
| 170 | module_id := MODULE.$(if \ |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 171 | $(LOCAL_IS_HOST_MODULE),$($(my_prefix)OS),TARGET).$(LOCAL_MODULE_CLASS).$(my_register_name) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 172 | ifdef $(module_id) |
| 173 | $(error $(LOCAL_PATH): $(module_id) already defined by $($(module_id))) |
| 174 | endif |
| 175 | $(module_id) := $(LOCAL_PATH) |
| 176 | |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 177 | intermediates := $(call local-intermediates-dir,,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 178 | intermediates.COMMON := $(call local-intermediates-dir,COMMON) |
Colin Cross | d826264 | 2014-01-24 23:17:21 -0800 | [diff] [blame] | 179 | generated_sources_dir := $(call local-generated-sources-dir) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 180 | |
| 181 | ########################################################### |
| 182 | # Pick a name for the intermediate and final targets |
| 183 | ########################################################### |
Colin Cross | 5a9db90 | 2014-03-21 12:27:37 -0700 | [diff] [blame] | 184 | include $(BUILD_SYSTEM)/configure_module_stem.mk |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 185 | |
| 186 | # OVERRIDE_BUILT_MODULE_PATH is only allowed to be used by the |
| 187 | # internal SHARED_LIBRARIES build files. |
| 188 | OVERRIDE_BUILT_MODULE_PATH := $(strip $(OVERRIDE_BUILT_MODULE_PATH)) |
| 189 | ifdef OVERRIDE_BUILT_MODULE_PATH |
| 190 | ifneq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES) |
| 191 | $(error $(LOCAL_PATH): Illegal use of OVERRIDE_BUILT_MODULE_PATH) |
| 192 | endif |
| 193 | built_module_path := $(OVERRIDE_BUILT_MODULE_PATH) |
| 194 | else |
| 195 | built_module_path := $(intermediates) |
| 196 | endif |
Ying Wang | 966c1e0 | 2014-05-20 14:43:51 -0700 | [diff] [blame] | 197 | LOCAL_BUILT_MODULE := $(built_module_path)/$(my_built_module_stem) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 198 | |
Ying Wang | 162991b | 2011-09-07 10:21:42 -0700 | [diff] [blame] | 199 | ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE)) |
Ying Wang | af9757e | 2014-07-17 21:24:42 -0700 | [diff] [blame] | 200 | # Apk and its attachments reside in its own subdir. |
| 201 | ifeq ($(LOCAL_MODULE_CLASS),APPS) |
| 202 | # framework-res.apk doesn't like the additional layer. |
| 203 | ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true) |
| 204 | my_module_path := $(my_module_path)/$(LOCAL_MODULE) |
| 205 | endif |
| 206 | endif |
Ying Wang | 966c1e0 | 2014-05-20 14:43:51 -0700 | [diff] [blame] | 207 | LOCAL_INSTALLED_MODULE := $(my_module_path)/$(my_installed_module_stem) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 208 | endif |
| 209 | |
| 210 | # Assemble the list of targets to create PRIVATE_ variables for. |
| 211 | LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE) |
| 212 | |
Yasuhiro Matsuda | ff82e82 | 2015-09-04 16:23:49 +0900 | [diff] [blame] | 213 | ########################################################### |
| 214 | ## logtags: Add .logtags files to global list |
| 215 | ########################################################### |
| 216 | |
| 217 | logtags_sources := $(filter %.logtags,$(LOCAL_SRC_FILES)) |
| 218 | |
| 219 | ifneq ($(strip $(logtags_sources)),) |
| 220 | event_log_tags := $(addprefix $(LOCAL_PATH)/,$(logtags_sources)) |
| 221 | else |
| 222 | event_log_tags := |
| 223 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 224 | |
| 225 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 226 | ## make clean- targets |
| 227 | ########################################################### |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 228 | cleantarget := clean-$(my_register_name) |
| 229 | $(cleantarget) : PRIVATE_MODULE := $(my_register_name) |
Ying Wang | 4d06341 | 2013-03-22 18:52:57 -0700 | [diff] [blame] | 230 | $(cleantarget) : PRIVATE_CLEAN_FILES := \ |
Ying Wang | 95221ca | 2012-11-07 14:07:34 -0800 | [diff] [blame] | 231 | $(LOCAL_BUILT_MODULE) \ |
| 232 | $(LOCAL_INSTALLED_MODULE) \ |
| 233 | $(intermediates) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 234 | $(cleantarget):: |
| 235 | @echo "Clean: $(PRIVATE_MODULE)" |
| 236 | $(hide) rm -rf $(PRIVATE_CLEAN_FILES) |
| 237 | |
| 238 | ########################################################### |
| 239 | ## Common definitions for module. |
| 240 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 241 | $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PATH:=$(LOCAL_PATH) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 242 | $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_IS_HOST_MODULE := $(LOCAL_IS_HOST_MODULE) |
| 243 | $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_HOST:= $(my_host) |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 244 | $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PREFIX := $(my_prefix) |
| 245 | |
Dima Zavin | 46e9bec | 2009-05-27 19:41:07 -0700 | [diff] [blame] | 246 | $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_INTERMEDIATES_DIR:= $(intermediates) |
Ying Wang | 6feb6d5 | 2014-04-17 10:03:35 -0700 | [diff] [blame] | 247 | $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_2ND_ARCH_VAR_PREFIX := $(LOCAL_2ND_ARCH_VAR_PREFIX) |
| 248 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 249 | # Tell the module and all of its sub-modules who it is. |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 250 | $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MODULE:= $(my_register_name) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 251 | |
| 252 | # Provide a short-hand for building this module. |
| 253 | # We name both BUILT and INSTALLED in case |
| 254 | # LOCAL_UNINSTALLABLE_MODULE is set. |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 255 | .PHONY: $(my_register_name) |
| 256 | $(my_register_name): $(LOCAL_BUILT_MODULE) $(LOCAL_INSTALLED_MODULE) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 257 | |
Ying Wang | caeaa08 | 2015-09-23 16:08:55 -0700 | [diff] [blame] | 258 | # Set up phony targets that covers all modules under the given paths. |
| 259 | # This allows us to build everything in given paths by running mmma/mma. |
| 260 | my_path_components := $(subst /,$(space),$(LOCAL_PATH)) |
| 261 | my_path_prefix := MODULES-IN |
| 262 | $(foreach c, $(my_path_components),\ |
Ying Wang | 61cd884 | 2015-09-24 16:19:19 -0700 | [diff] [blame^] | 263 | $(eval my_path_prefix := $(my_path_prefix)-$(c))\ |
Ying Wang | caeaa08 | 2015-09-23 16:08:55 -0700 | [diff] [blame] | 264 | $(eval .PHONY : $(my_path_prefix))\ |
| 265 | $(eval $(my_path_prefix) : $(my_register_name))) |
| 266 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 267 | ########################################################### |
| 268 | ## Module installation rule |
| 269 | ########################################################### |
| 270 | |
| 271 | # Some hosts do not have ACP; override the LOCAL version if that's the case. |
| 272 | ifneq ($(strip $(HOST_ACP_UNAVAILABLE)),) |
| 273 | LOCAL_ACP_UNAVAILABLE := $(strip $(HOST_ACP_UNAVAILABLE)) |
| 274 | endif |
| 275 | |
| 276 | ifndef LOCAL_UNINSTALLABLE_MODULE |
| 277 | # Define a copy rule to install the module. |
| 278 | # acp and libraries that it uses can't use acp for |
| 279 | # installation; hence, LOCAL_ACP_UNAVAILABLE. |
Ying Wang | e56605a | 2013-02-06 11:44:41 -0800 | [diff] [blame] | 280 | $(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 281 | ifneq ($(LOCAL_ACP_UNAVAILABLE),true) |
| 282 | $(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE) | $(ACP) |
| 283 | @echo "Install: $@" |
Ying Wang | 84ed6fa | 2011-01-18 17:21:20 -0800 | [diff] [blame] | 284 | $(copy-file-to-new-target) |
Ying Wang | e56605a | 2013-02-06 11:44:41 -0800 | [diff] [blame] | 285 | $(PRIVATE_POST_INSTALL_CMD) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 286 | else |
| 287 | $(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE) |
| 288 | @echo "Install: $@" |
| 289 | $(copy-file-to-target-with-cp) |
| 290 | endif |
| 291 | |
Ying Wang | 9fe15ac | 2015-08-20 12:02:10 -0700 | [diff] [blame] | 292 | # Rule to install the module's companion init.rc. |
| 293 | my_init_rc := $(LOCAL_INIT_RC_$(my_32_64_bit_suffix)) |
| 294 | my_init_rc_src := |
| 295 | my_init_rc_installed := |
| 296 | ifndef my_init_rc |
| 297 | my_init_rc := $(LOCAL_INIT_RC) |
| 298 | # Make sure we don't define the rule twice in multilib module. |
| 299 | LOCAL_INIT_RC := |
| 300 | endif |
| 301 | ifdef my_init_rc |
| 302 | my_init_rc_src := $(LOCAL_PATH)/$(my_init_rc) |
| 303 | my_init_rc_installed := $(TARGET_OUT$(partition_tag)_ETC)/init/$(notdir $(my_init_rc_src)) |
| 304 | $(my_init_rc_installed) : $(my_init_rc_src) | $(ACP) |
| 305 | @echo "Install: $@" |
| 306 | $(copy-file-to-new-target) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 307 | |
Ying Wang | 9fe15ac | 2015-08-20 12:02:10 -0700 | [diff] [blame] | 308 | $(my_register_name) : $(my_init_rc_installed) |
| 309 | endif # my_init_rc |
| 310 | endif # !LOCAL_UNINSTALLABLE_MODULE |
Joe Onorato | e334d25 | 2009-07-17 15:33:40 -0400 | [diff] [blame] | 311 | |
| 312 | ########################################################### |
| 313 | ## CHECK_BUILD goals |
| 314 | ########################################################### |
Ying Wang | 6c1d1cc | 2014-09-29 14:34:32 -0700 | [diff] [blame] | 315 | my_checked_module := |
Joe Onorato | e334d25 | 2009-07-17 15:33:40 -0400 | [diff] [blame] | 316 | # If nobody has defined a more specific module for the |
Ying Wang | 5a8d345 | 2013-01-30 14:43:05 -0800 | [diff] [blame] | 317 | # checked modules, use LOCAL_BUILT_MODULE. |
Ying Wang | 6c1d1cc | 2014-09-29 14:34:32 -0700 | [diff] [blame] | 318 | ifdef LOCAL_CHECKED_MODULE |
| 319 | my_checked_module := $(LOCAL_CHECKED_MODULE) |
| 320 | else |
| 321 | my_checked_module := $(LOCAL_BUILT_MODULE) |
Joe Onorato | e334d25 | 2009-07-17 15:33:40 -0400 | [diff] [blame] | 322 | endif |
| 323 | |
| 324 | # If they request that this module not be checked, then don't. |
| 325 | # PLEASE DON'T SET THIS. ANY PLACES THAT SET THIS WITHOUT |
| 326 | # GOOD REASON WILL HAVE IT REMOVED. |
| 327 | ifdef LOCAL_DONT_CHECK_MODULE |
Ying Wang | 6c1d1cc | 2014-09-29 14:34:32 -0700 | [diff] [blame] | 328 | my_checked_module := |
Joe Onorato | e334d25 | 2009-07-17 15:33:40 -0400 | [diff] [blame] | 329 | endif |
Ying Wang | 966c1e0 | 2014-05-20 14:43:51 -0700 | [diff] [blame] | 330 | # Don't check build target module defined for the 2nd arch |
| 331 | ifndef LOCAL_IS_HOST_MODULE |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 332 | ifdef LOCAL_2ND_ARCH_VAR_PREFIX |
Ying Wang | 6c1d1cc | 2014-09-29 14:34:32 -0700 | [diff] [blame] | 333 | my_checked_module := |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 334 | endif |
Ying Wang | 966c1e0 | 2014-05-20 14:43:51 -0700 | [diff] [blame] | 335 | endif |
Joe Onorato | e334d25 | 2009-07-17 15:33:40 -0400 | [diff] [blame] | 336 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 337 | ########################################################### |
| 338 | ## Register with ALL_MODULES |
| 339 | ########################################################### |
| 340 | |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 341 | ALL_MODULES += $(my_register_name) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 342 | |
| 343 | # Don't use += on subvars, or else they'll end up being |
| 344 | # recursively expanded. |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 345 | ALL_MODULES.$(my_register_name).CLASS := \ |
| 346 | $(ALL_MODULES.$(my_register_name).CLASS) $(LOCAL_MODULE_CLASS) |
| 347 | ALL_MODULES.$(my_register_name).PATH := \ |
| 348 | $(ALL_MODULES.$(my_register_name).PATH) $(LOCAL_PATH) |
| 349 | ALL_MODULES.$(my_register_name).TAGS := \ |
Ying Wang | 37bd1f2 | 2014-01-27 15:19:09 -0800 | [diff] [blame] | 350 | $(ALL_MODULES.$(my_register_name).TAGS) $(my_module_tags) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 351 | ALL_MODULES.$(my_register_name).CHECKED := \ |
Ying Wang | 6c1d1cc | 2014-09-29 14:34:32 -0700 | [diff] [blame] | 352 | $(ALL_MODULES.$(my_register_name).CHECKED) $(my_checked_module) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 353 | ALL_MODULES.$(my_register_name).BUILT := \ |
| 354 | $(ALL_MODULES.$(my_register_name).BUILT) $(LOCAL_BUILT_MODULE) |
Ying Wang | 3380d3a | 2014-05-19 13:03:36 -0700 | [diff] [blame] | 355 | ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE)) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 356 | ALL_MODULES.$(my_register_name).INSTALLED := \ |
Ying Wang | 9fe15ac | 2015-08-20 12:02:10 -0700 | [diff] [blame] | 357 | $(strip $(ALL_MODULES.$(my_register_name).INSTALLED) \ |
| 358 | $(LOCAL_INSTALLED_MODULE) $(my_init_rc_installed)) |
Ying Wang | 3380d3a | 2014-05-19 13:03:36 -0700 | [diff] [blame] | 359 | ALL_MODULES.$(my_register_name).BUILT_INSTALLED := \ |
Ying Wang | 9fe15ac | 2015-08-20 12:02:10 -0700 | [diff] [blame] | 360 | $(strip $(ALL_MODULES.$(my_register_name).BUILT_INSTALLED) \ |
| 361 | $(LOCAL_BUILT_MODULE):$(LOCAL_INSTALLED_MODULE) \ |
| 362 | $(addprefix $(my_init_rc_src):,$(my_init_rc_installed))) |
Ying Wang | 3380d3a | 2014-05-19 13:03:36 -0700 | [diff] [blame] | 363 | endif |
Ying Wang | 3b81aab | 2014-05-05 16:46:52 -0700 | [diff] [blame] | 364 | ifdef LOCAL_PICKUP_FILES |
| 365 | # Files or directories ready to pick up by the build system |
| 366 | # when $(LOCAL_BUILT_MODULE) is done. |
| 367 | ALL_MODULES.$(my_register_name).PICKUP_FILES := \ |
| 368 | $(ALL_MODULES.$(my_register_name).PICKUP_FILES) $(LOCAL_PICKUP_FILES) |
| 369 | endif |
Dan Willemsen | 7a54985 | 2015-08-13 17:51:40 -0700 | [diff] [blame] | 370 | my_required_modules := $(LOCAL_REQUIRED_MODULES) \ |
| 371 | $(LOCAL_REQUIRED_MODULES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) |
| 372 | ifdef LOCAL_IS_HOST_MODULE |
| 373 | my_required_modules += $(LOCAL_REQUIRED_MODULES_$($(my_prefix)OS)) |
| 374 | endif |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 375 | ALL_MODULES.$(my_register_name).REQUIRED := \ |
Dan Willemsen | 7a54985 | 2015-08-13 17:51:40 -0700 | [diff] [blame] | 376 | $(strip $(ALL_MODULES.$(my_register_name).REQUIRED) $(my_required_modules)) |
Yasuhiro Matsuda | ff82e82 | 2015-09-04 16:23:49 +0900 | [diff] [blame] | 377 | ALL_MODULES.$(my_register_name).EVENT_LOG_TAGS := \ |
| 378 | $(ALL_MODULES.$(my_register_name).EVENT_LOG_TAGS) $(event_log_tags) |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 379 | ALL_MODULES.$(my_register_name).MAKEFILE := \ |
| 380 | $(ALL_MODULES.$(my_register_name).MAKEFILE) $(LOCAL_MODULE_MAKEFILE) |
Ying Wang | dbb31be | 2011-12-09 15:11:57 -0800 | [diff] [blame] | 381 | ifdef LOCAL_MODULE_OWNER |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 382 | ALL_MODULES.$(my_register_name).OWNER := \ |
| 383 | $(sort $(ALL_MODULES.$(my_register_name).OWNER) $(LOCAL_MODULE_OWNER)) |
Ying Wang | dbb31be | 2011-12-09 15:11:57 -0800 | [diff] [blame] | 384 | endif |
Ying Wang | 14a6cbd | 2014-02-10 22:26:23 -0800 | [diff] [blame] | 385 | ifdef LOCAL_2ND_ARCH_VAR_PREFIX |
| 386 | ALL_MODULES.$(my_register_name).FOR_2ND_ARCH := true |
| 387 | endif |
Dan Willemsen | 057aaea | 2015-08-14 12:59:50 -0700 | [diff] [blame] | 388 | ALL_MODULES.$(my_register_name).FOR_HOST_CROSS := $(my_host_cross) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 389 | |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 390 | INSTALLABLE_FILES.$(LOCAL_INSTALLED_MODULE).MODULE := $(my_register_name) |
Joe Onorato | 8a06bac | 2010-05-21 14:29:29 -0700 | [diff] [blame] | 391 | |
Ying Wang | 39b9b69 | 2015-05-07 12:08:53 -0700 | [diff] [blame] | 392 | ########################################################## |
| 393 | # Track module-level dependencies. |
| 394 | # Use $(LOCAL_MODULE) instead of $(my_register_name) to ignore module's bitness. |
| 395 | ALL_DEPS.MODULES := $(sort $(ALL_DEPS.MODULES) $(LOCAL_MODULE)) |
| 396 | ALL_DEPS.$(LOCAL_MODULE).ALL_DEPS := $(sort \ |
| 397 | $(ALL_MODULES.$(LOCAL_MODULE).ALL_DEPS) \ |
| 398 | $(LOCAL_STATIC_LIBRARIES) \ |
| 399 | $(LOCAL_WHOLE_STATIC_LIBRARIES) \ |
| 400 | $(LOCAL_SHARED_LIBRARIES) \ |
| 401 | $(LOCAL_STATIC_JAVA_LIBRARIES) \ |
| 402 | $(LOCAL_JAVA_LIBRARIES)\ |
| 403 | $(LOCAL_JNI_SHARED_LIBRARIES)) |
| 404 | |
| 405 | ALL_DEPS.$(LOCAL_MODULE).LICENSE := $(sort $(ALL_DEPS.$(LOCAL_MODULE).LICENSE) $(license_files)) |
| 406 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 407 | ########################################################### |
Ying Wang | 37bd1f2 | 2014-01-27 15:19:09 -0800 | [diff] [blame] | 408 | ## Take care of my_module_tags |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 409 | ########################################################### |
| 410 | |
| 411 | # Keep track of all the tags we've seen. |
Ying Wang | 37bd1f2 | 2014-01-27 15:19:09 -0800 | [diff] [blame] | 412 | ALL_MODULE_TAGS := $(sort $(ALL_MODULE_TAGS) $(my_module_tags)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 413 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 414 | # Add this module name to the tag list of each specified tag. |
Ying Wang | 37bd1f2 | 2014-01-27 15:19:09 -0800 | [diff] [blame] | 415 | $(foreach tag,$(my_module_tags),\ |
Ying Wang | 6ef6519 | 2014-01-15 16:02:16 -0800 | [diff] [blame] | 416 | $(eval ALL_MODULE_NAME_TAGS.$(tag) += $(my_register_name))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 417 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 418 | ########################################################### |
Ying Wang | ef4d82f | 2013-01-29 16:59:18 -0800 | [diff] [blame] | 419 | ## umbrella targets used to verify builds |
| 420 | ########################################################### |
Ying Wang | ef4d82f | 2013-01-29 16:59:18 -0800 | [diff] [blame] | 421 | j_or_n := |
| 422 | ifneq (,$(filter EXECUTABLES SHARED_LIBRARIES STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS))) |
| 423 | j_or_n := native |
| 424 | else |
| 425 | ifneq (,$(filter JAVA_LIBRARIES APPS,$(LOCAL_MODULE_CLASS))) |
| 426 | j_or_n := java |
Ying Wang | ef4d82f | 2013-01-29 16:59:18 -0800 | [diff] [blame] | 427 | endif |
| 428 | endif |
| 429 | ifdef LOCAL_IS_HOST_MODULE |
| 430 | h_or_t := host |
| 431 | else |
| 432 | h_or_t := target |
| 433 | endif |
| 434 | |
| 435 | ifdef j_or_n |
Ying Wang | 6c1d1cc | 2014-09-29 14:34:32 -0700 | [diff] [blame] | 436 | $(j_or_n) $(h_or_t) $(j_or_n)-$(h_or_t) : $(my_checked_module) |
Ying Wang | 37bd1f2 | 2014-01-27 15:19:09 -0800 | [diff] [blame] | 437 | ifneq (,$(filter $(my_module_tags),tests)) |
Ying Wang | 6c1d1cc | 2014-09-29 14:34:32 -0700 | [diff] [blame] | 438 | $(j_or_n)-$(h_or_t)-tests $(j_or_n)-tests $(h_or_t)-tests : $(my_checked_module) |
Ying Wang | ef4d82f | 2013-01-29 16:59:18 -0800 | [diff] [blame] | 439 | endif |
| 440 | endif |
| 441 | |
| 442 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 443 | ## NOTICE files |
| 444 | ########################################################### |
| 445 | |
Ying Wang | 13d6950 | 2012-11-01 17:22:33 -0700 | [diff] [blame] | 446 | include $(BUILD_NOTICE_FILE) |