blob: a8c477e2640b5f9ff7a24281aa40f033671ca26d [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001#
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
Dan Willemsen3bf15e72016-07-25 16:03:53 -070017# Catch users that directly include base_rules.mk
18$(call record-module-type,base_rules)
19
The Android Open Source Project88b60792009-03-03 19:28:42 -080020# Users can define base-rules-hook in their buildspec.mk to perform
21# arbitrary operations as each module is included.
22ifdef base-rules-hook
23$(if $(base-rules-hook),)
24endif
25
26###########################################################
27## Common instructions for a generic module.
28###########################################################
29
30LOCAL_MODULE := $(strip $(LOCAL_MODULE))
31ifeq ($(LOCAL_MODULE),)
32 $(error $(LOCAL_PATH): LOCAL_MODULE is not defined)
33endif
34
35LOCAL_IS_HOST_MODULE := $(strip $(LOCAL_IS_HOST_MODULE))
Alexey Polyudovccdc3112016-08-01 17:41:49 -070036LOCAL_IS_AUX_MODULE := $(strip $(LOCAL_IS_AUX_MODULE))
The Android Open Source Project88b60792009-03-03 19:28:42 -080037ifdef LOCAL_IS_HOST_MODULE
38 ifneq ($(LOCAL_IS_HOST_MODULE),true)
39 $(error $(LOCAL_PATH): LOCAL_IS_HOST_MODULE must be "true" or empty, not "$(LOCAL_IS_HOST_MODULE)")
40 endif
Dan Willemsen057aaea2015-08-14 12:59:50 -070041 ifeq ($(LOCAL_HOST_PREFIX),)
42 my_prefix := HOST_
43 else
44 my_prefix := $(LOCAL_HOST_PREFIX)
45 endif
Ying Wang13d69502012-11-01 17:22:33 -070046 my_host := host-
Alexey Polyudovccdc3112016-08-01 17:41:49 -070047 my_kind := HOST
The Android Open Source Project88b60792009-03-03 19:28:42 -080048else
Alexey Polyudovccdc3112016-08-01 17:41:49 -070049 ifdef LOCAL_IS_AUX_MODULE
50 ifneq ($(LOCAL_IS_AUX_MODULE),true)
51 $(error $(LOCAL_PATH): LOCAL_IS_AUX_MODULE must be "true" or empty, not "$(LOCAL_IS_AUX_MODULE)")
52 endif
53 my_prefix := AUX_
54 my_kind := AUX
55 else
56 my_prefix := TARGET_
57 my_kind :=
58 endif
Ying Wang13d69502012-11-01 17:22:33 -070059 my_host :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080060endif
61
Dan Willemsen057aaea2015-08-14 12:59:50 -070062ifeq ($(my_prefix),HOST_CROSS_)
63 my_host_cross := true
64else
65 my_host_cross :=
66endif
67
Dan Willemsenbab0fa62016-11-18 14:05:39 -080068include $(BUILD_SYSTEM)/local_vndk.mk
69
Ying Wang37bd1f22014-01-27 15:19:09 -080070my_module_tags := $(LOCAL_MODULE_TAGS)
Dan Willemsen057aaea2015-08-14 12:59:50 -070071ifeq ($(my_host_cross),true)
72 my_module_tags :=
73endif
Ying Wang87538e42016-03-16 19:53:19 -070074ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
75ifdef LOCAL_2ND_ARCH_VAR_PREFIX
76# Don't pull in modules by tags if this is for translation TARGET_2ND_ARCH.
77 my_module_tags :=
78endif
79endif
Ying Wang37bd1f22014-01-27 15:19:09 -080080
Colin Crossa4447e82015-09-28 16:26:00 -070081# Ninja has an implicit dependency on the command being run, and kati will
82# regenerate the ninja manifest if any read makefile changes, so there is no
83# need to have dependencies on makefiles.
84# This won't catch all the cases where LOCAL_ADDITIONAL_DEPENDENCIES contains
85# a .mk file, because a few users of LOCAL_ADDITIONAL_DEPENDENCIES don't include
86# base_rules.mk, but it will fix the most common ones.
87LOCAL_ADDITIONAL_DEPENDENCIES := $(filter-out %.mk,$(LOCAL_ADDITIONAL_DEPENDENCIES))
Colin Crossa4447e82015-09-28 16:26:00 -070088
The Android Open Source Project88b60792009-03-03 19:28:42 -080089###########################################################
90## Validate and define fallbacks for input LOCAL_* variables.
91###########################################################
92
93## Dump a .csv file of all modules and their tags
94#ifneq ($(tag-list-first-time),false)
95#$(shell rm -f tag-list.csv)
96#tag-list-first-time := false
97#endif
Ying Wang37bd1f22014-01-27 15:19:09 -080098#$(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 Project88b60792009-03-03 19:28:42 -080099
Ying Wang6e371e42012-05-15 14:31:26 -0700100LOCAL_UNINSTALLABLE_MODULE := $(strip $(LOCAL_UNINSTALLABLE_MODULE))
Ying Wang37bd1f22014-01-27 15:19:09 -0800101my_module_tags := $(sort $(my_module_tags))
102ifeq (,$(my_module_tags))
103 my_module_tags := optional
Ying Wang2fd81cf2010-12-10 11:17:28 -0800104endif
Joe Onorato918ee312012-05-18 20:43:14 -0700105
Joe Onorato6a185e42012-05-22 14:08:50 -0700106# User tags are not allowed anymore. Fail early because it will not be installed
107# like it used to be.
Ying Wang37bd1f22014-01-27 15:19:09 -0800108ifneq ($(filter $(my_module_tags),user),)
Joe Onorato6a185e42012-05-22 14:08:50 -0700109 $(warning *** Module name: $(LOCAL_MODULE))
110 $(warning *** Makefile location: $(LOCAL_MODULE_MAKEFILE))
111 $(warning * )
112 $(warning * Module is attempting to use the 'user' tag. This)
113 $(warning * used to cause the module to be installed automatically.)
114 $(warning * Now, the module must be listed in the PRODUCT_PACKAGES)
115 $(warning * section of a product makefile to have it installed.)
116 $(warning * )
117 $(error user tag detected on module.)
118endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800119
Jean-Baptiste Querua831cbd2010-01-07 11:06:50 -0800120# Only the tags mentioned in this test are expected to be set by module
121# makefiles. Anything else is either a typo or a source of unexpected
122# behaviors.
Ying Wang37bd1f22014-01-27 15:19:09 -0800123ifneq ($(filter-out debug eng tests optional samples,$(my_module_tags)),)
124$(warning unusual tags $(my_module_tags) on $(LOCAL_MODULE) at $(LOCAL_PATH))
Jean-Baptiste Querua831cbd2010-01-07 11:06:50 -0800125endif
126
The Android Open Source Project88b60792009-03-03 19:28:42 -0800127# Add implicit tags.
128#
129# If the local directory or one of its parents contains a MODULE_LICENSE_GPL
Andrew Boie08a943b2013-12-10 13:52:00 -0800130# file, tag the module as "gnu". Search for "*_GPL*", "*_LGPL*" and "*_MPL*"
131# so that we can also find files like MODULE_LICENSE_GPL_AND_AFL
The Android Open Source Project88b60792009-03-03 19:28:42 -0800132#
Ying Wang39b9b692015-05-07 12:08:53 -0700133license_files := $(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*)
Andrew Boie08a943b2013-12-10 13:52:00 -0800134gpl_license_file := $(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*_GPL* MODULE_LICENSE*_MPL* MODULE_LICENSE*_LGPL*)
Ying Wangfd626f22011-12-12 12:57:38 -0800135ifneq ($(gpl_license_file),)
Ying Wang37bd1f22014-01-27 15:19:09 -0800136 my_module_tags += gnu
Ying Wangfd626f22011-12-12 12:57:38 -0800137 ALL_GPL_MODULE_LICENSE_FILES := $(sort $(ALL_GPL_MODULE_LICENSE_FILES) $(gpl_license_file))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800138endif
139
The Android Open Source Project88b60792009-03-03 19:28:42 -0800140LOCAL_MODULE_CLASS := $(strip $(LOCAL_MODULE_CLASS))
141ifneq ($(words $(LOCAL_MODULE_CLASS)),1)
142 $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS must contain exactly one word, not "$(LOCAL_MODULE_CLASS)")
143endif
144
Ying Wang6feb6d52014-04-17 10:03:35 -0700145my_32_64_bit_suffix := $(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT),64,32)
Colin Cross87974052014-03-21 12:25:44 -0700146
Ying Wang6e371e42012-05-15 14:31:26 -0700147ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
Ying Wang87538e42016-03-16 19:53:19 -0700148ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
149# When in TARGET_TRANSLATE_2ND_ARCH both TARGET_ARCH and TARGET_2ND_ARCH are 32-bit,
150# to avoid path conflict we force using LOCAL_MODULE_PATH_64 for the first arch.
151ifdef LOCAL_2ND_ARCH_VAR_PREFIX
152my_multilib_module_path := $(LOCAL_MODULE_PATH_32)
153else # ! LOCAL_2ND_ARCH_VAR_PREFIX
154my_multilib_module_path := $(LOCAL_MODULE_PATH_64)
155endif # ! LOCAL_2ND_ARCH_VAR_PREFIX
156else # ! TARGET_TRANSLATE_2ND_ARCH
Colin Cross87974052014-03-21 12:25:44 -0700157my_multilib_module_path := $(strip $(LOCAL_MODULE_PATH_$(my_32_64_bit_suffix)))
Ying Wang87538e42016-03-16 19:53:19 -0700158endif # ! TARGET_TRANSLATE_2ND_ARCH
Colin Cross87974052014-03-21 12:25:44 -0700159ifdef my_multilib_module_path
160my_module_path := $(my_multilib_module_path)
161else
Ying Wangb8e01852014-01-23 15:09:04 -0800162my_module_path := $(strip $(LOCAL_MODULE_PATH))
Colin Cross87974052014-03-21 12:25:44 -0700163endif
Dan Willemsene0bba6f2016-12-09 21:15:41 -0800164my_module_path := $(patsubst %/,%,$(my_module_path))
Colin Cross639c3362014-01-24 19:23:40 -0800165my_module_relative_path := $(strip $(LOCAL_MODULE_RELATIVE_PATH))
Dan Willemsenb2a5c7b2017-02-13 13:41:43 -0800166ifdef LOCAL_IS_HOST_MODULE
167 partition_tag :=
168else
169ifeq (true,$(LOCAL_PROPRIETARY_MODULE))
170 partition_tag := _VENDOR
171else ifeq (true,$(LOCAL_OEM_MODULE))
172 partition_tag := _OEM
173else ifeq (true,$(LOCAL_ODM_MODULE))
174 partition_tag := _ODM
175else ifeq (NATIVE_TESTS,$(LOCAL_MODULE_CLASS))
176 partition_tag := _DATA
177else
178 # The definition of should-install-to-system will be different depending
179 # on which goal (e.g., sdk or just droid) is being built.
180 partition_tag := $(if $(call should-install-to-system,$(my_module_tags)),,_DATA)
181endif
182endif
Ying Wangb8e01852014-01-23 15:09:04 -0800183ifeq ($(my_module_path),)
Ying Wang6ef65192014-01-15 16:02:16 -0800184 install_path_var := $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT$(partition_tag)_$(LOCAL_MODULE_CLASS)
Ying Wang5338fbf2013-05-08 15:49:08 -0700185 ifeq (true,$(LOCAL_PRIVILEGED_MODULE))
186 install_path_var := $(install_path_var)_PRIVILEGED
187 endif
188
Colin Crossb34911c2014-01-22 17:34:28 -0800189 my_module_path := $($(install_path_var))
Ying Wangb8e01852014-01-23 15:09:04 -0800190 ifeq ($(strip $(my_module_path)),)
191 $(error $(LOCAL_PATH): unhandled install path "$(install_path_var) for $(LOCAL_MODULE)")
The Android Open Source Project88b60792009-03-03 19:28:42 -0800192 endif
193endif
Colin Cross639c3362014-01-24 19:23:40 -0800194ifneq ($(my_module_relative_path),)
195 my_module_path := $(my_module_path)/$(my_module_relative_path)
196endif
Ying Wang6e371e42012-05-15 14:31:26 -0700197endif # not LOCAL_UNINSTALLABLE_MODULE
The Android Open Source Project88b60792009-03-03 19:28:42 -0800198
199ifneq ($(strip $(LOCAL_BUILT_MODULE)$(LOCAL_INSTALLED_MODULE)),)
200 $(error $(LOCAL_PATH): LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE must not be defined by component makefiles)
201endif
202
Ying Wang6ef65192014-01-15 16:02:16 -0800203my_register_name := $(LOCAL_MODULE)
Dan Willemsen057aaea2015-08-14 12:59:50 -0700204ifeq ($(my_host_cross),true)
205 my_register_name := host_cross_$(LOCAL_MODULE)
206endif
Dan Willemsen9ecbf832016-02-05 16:20:19 -0800207ifdef LOCAL_2ND_ARCH_VAR_PREFIX
208ifndef LOCAL_NO_2ND_ARCH_MODULE_SUFFIX
209my_register_name := $(my_register_name)$($(my_prefix)2ND_ARCH_MODULE_SUFFIX)
210endif
211endif
Alexey Polyudovccdc3112016-08-01 17:41:49 -0700212
Colin Crossaaf888a2016-09-07 12:48:30 -0700213ifeq ($(my_host_cross),true)
214 my_all_targets := host_cross_$(my_register_name)_all_targets
215else ifneq ($(LOCAL_IS_HOST_MODULE),)
216 my_all_targets := host_$(my_register_name)_all_targets
217else
218 my_all_targets := device_$(my_register_name)_all_targets
219endif
220
Alexey Polyudovccdc3112016-08-01 17:41:49 -0700221# variant is enough to make nano class unique; it serves as a key to lookup (OS,ARCH) tuple
222aux_class := $($(my_prefix)OS_VARIANT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800223# Make sure that this IS_HOST/CLASS/MODULE combination is unique.
224module_id := MODULE.$(if \
Alexey Polyudovccdc3112016-08-01 17:41:49 -0700225 $(LOCAL_IS_HOST_MODULE),$($(my_prefix)OS),$(if \
226 $(LOCAL_IS_AUX_MODULE),$(aux_class),TARGET)).$(LOCAL_MODULE_CLASS).$(my_register_name)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800227ifdef $(module_id)
228$(error $(LOCAL_PATH): $(module_id) already defined by $($(module_id)))
229endif
230$(module_id) := $(LOCAL_PATH)
231
Dan Willemsen057aaea2015-08-14 12:59:50 -0700232intermediates := $(call local-intermediates-dir,,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800233intermediates.COMMON := $(call local-intermediates-dir,COMMON)
Colin Crossd8262642014-01-24 23:17:21 -0800234generated_sources_dir := $(call local-generated-sources-dir)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800235
236###########################################################
237# Pick a name for the intermediate and final targets
238###########################################################
Colin Cross5a9db902014-03-21 12:27:37 -0700239include $(BUILD_SYSTEM)/configure_module_stem.mk
The Android Open Source Project88b60792009-03-03 19:28:42 -0800240
241# OVERRIDE_BUILT_MODULE_PATH is only allowed to be used by the
242# internal SHARED_LIBRARIES build files.
243OVERRIDE_BUILT_MODULE_PATH := $(strip $(OVERRIDE_BUILT_MODULE_PATH))
244ifdef OVERRIDE_BUILT_MODULE_PATH
245 ifneq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
246 $(error $(LOCAL_PATH): Illegal use of OVERRIDE_BUILT_MODULE_PATH)
247 endif
248 built_module_path := $(OVERRIDE_BUILT_MODULE_PATH)
249else
250 built_module_path := $(intermediates)
251endif
Ying Wang966c1e02014-05-20 14:43:51 -0700252LOCAL_BUILT_MODULE := $(built_module_path)/$(my_built_module_stem)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800253
Ying Wang162991b2011-09-07 10:21:42 -0700254ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
Ying Wangaf9757e2014-07-17 21:24:42 -0700255 # Apk and its attachments reside in its own subdir.
256 ifeq ($(LOCAL_MODULE_CLASS),APPS)
257 # framework-res.apk doesn't like the additional layer.
Jakub Adameka08a1012016-10-03 09:56:16 +0100258 ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
259 # Neither do Runtime Resource Overlay apks, which contain just the overlaid resources.
260 else ifeq ($(LOCAL_IS_RUNTIME_RESOURCE_OVERLAY),true)
261 else
Ying Wangaf9757e2014-07-17 21:24:42 -0700262 my_module_path := $(my_module_path)/$(LOCAL_MODULE)
263 endif
264 endif
Ying Wang966c1e02014-05-20 14:43:51 -0700265 LOCAL_INSTALLED_MODULE := $(my_module_path)/$(my_installed_module_stem)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800266endif
267
268# Assemble the list of targets to create PRIVATE_ variables for.
269LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE)
270
Yasuhiro Matsudaff82e822015-09-04 16:23:49 +0900271###########################################################
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +0900272## Create .toc files from shared objects to reduce unnecessary rebuild
273# .toc files have the list of external dynamic symbols without their addresses.
Shinichiro Hamaji89b255a2015-11-09 16:47:42 +0900274# As .KATI_RESTAT is specified to .toc files and commit-change-for-toc is used,
275# dependent binaries of a .toc file will be rebuilt only when the content of
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +0900276# the .toc file is changed.
277###########################################################
278ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
279LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE).toc
280$(LOCAL_BUILT_MODULE).toc: $(LOCAL_BUILT_MODULE)
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +0900281 $(call $(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)transform-shared-lib-to-toc,$<,$@.tmp)
Shinichiro Hamaji89b255a2015-11-09 16:47:42 +0900282 $(call commit-change-for-toc,$@)
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +0900283
284# Kati adds restat=1 to ninja. GNU make does nothing for this.
285.KATI_RESTAT: $(LOCAL_BUILT_MODULE).toc
Colin Crosse2b8f682016-02-04 13:28:04 -0800286# Build .toc file when using mm, mma, or make $(my_register_name)
Colin Crossaaf888a2016-09-07 12:48:30 -0700287$(my_all_targets): $(LOCAL_BUILT_MODULE).toc
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +0900288endif
289
290###########################################################
Yasuhiro Matsudaff82e822015-09-04 16:23:49 +0900291## logtags: Add .logtags files to global list
292###########################################################
293
Dan Willemsenb0a08b82016-06-01 15:27:11 -0700294logtags_sources := $(filter %.logtags,$(LOCAL_SRC_FILES)) $(LOCAL_LOGTAGS_FILES)
Yasuhiro Matsudaff82e822015-09-04 16:23:49 +0900295
296ifneq ($(strip $(logtags_sources)),)
297event_log_tags := $(addprefix $(LOCAL_PATH)/,$(logtags_sources))
298else
299event_log_tags :=
300endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800301
302###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800303## make clean- targets
304###########################################################
Ying Wang6ef65192014-01-15 16:02:16 -0800305cleantarget := clean-$(my_register_name)
306$(cleantarget) : PRIVATE_MODULE := $(my_register_name)
Ying Wang4d063412013-03-22 18:52:57 -0700307$(cleantarget) : PRIVATE_CLEAN_FILES := \
Ying Wang95221ca2012-11-07 14:07:34 -0800308 $(LOCAL_BUILT_MODULE) \
309 $(LOCAL_INSTALLED_MODULE) \
310 $(intermediates)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800311$(cleantarget)::
312 @echo "Clean: $(PRIVATE_MODULE)"
313 $(hide) rm -rf $(PRIVATE_CLEAN_FILES)
314
315###########################################################
316## Common definitions for module.
317###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800318$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PATH:=$(LOCAL_PATH)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800319$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_IS_HOST_MODULE := $(LOCAL_IS_HOST_MODULE)
Alexey Polyudovccdc3112016-08-01 17:41:49 -0700320$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_IS_AUX_MODULE := $(LOCAL_IS_AUX_MODULE)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800321$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_HOST:= $(my_host)
Dan Willemsen057aaea2015-08-14 12:59:50 -0700322$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PREFIX := $(my_prefix)
323
Dima Zavin46e9bec2009-05-27 19:41:07 -0700324$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_INTERMEDIATES_DIR:= $(intermediates)
Ying Wang6feb6d52014-04-17 10:03:35 -0700325$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_2ND_ARCH_VAR_PREFIX := $(LOCAL_2ND_ARCH_VAR_PREFIX)
326
The Android Open Source Project88b60792009-03-03 19:28:42 -0800327# Tell the module and all of its sub-modules who it is.
Ying Wang6ef65192014-01-15 16:02:16 -0800328$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MODULE:= $(my_register_name)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800329
330# Provide a short-hand for building this module.
331# We name both BUILT and INSTALLED in case
332# LOCAL_UNINSTALLABLE_MODULE is set.
Colin Crossaaf888a2016-09-07 12:48:30 -0700333.PHONY: $(my_all_targets)
334$(my_all_targets): $(LOCAL_BUILT_MODULE) $(LOCAL_INSTALLED_MODULE)
335
Ying Wang6ef65192014-01-15 16:02:16 -0800336.PHONY: $(my_register_name)
Colin Crossaaf888a2016-09-07 12:48:30 -0700337$(my_register_name): $(my_all_targets)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800338
Ying Wang71c58092016-03-23 11:02:03 -0700339ifneq ($(my_register_name),$(LOCAL_MODULE))
340# $(LOCAL_MODULE) covers all the multilib targets.
341.PHONY: $(LOCAL_MODULE)
Colin Crossaaf888a2016-09-07 12:48:30 -0700342$(LOCAL_MODULE) : $(my_all_targets)
Ying Wang71c58092016-03-23 11:02:03 -0700343endif
344
Ying Wangcaeaa082015-09-23 16:08:55 -0700345# Set up phony targets that covers all modules under the given paths.
346# This allows us to build everything in given paths by running mmma/mma.
347my_path_components := $(subst /,$(space),$(LOCAL_PATH))
348my_path_prefix := MODULES-IN
349$(foreach c, $(my_path_components),\
Ying Wang61cd8842015-09-24 16:19:19 -0700350 $(eval my_path_prefix := $(my_path_prefix)-$(c))\
Ying Wangcaeaa082015-09-23 16:08:55 -0700351 $(eval .PHONY : $(my_path_prefix))\
Colin Crossaaf888a2016-09-07 12:48:30 -0700352 $(eval $(my_path_prefix) : $(my_all_targets)))
Ying Wangcaeaa082015-09-23 16:08:55 -0700353
The Android Open Source Project88b60792009-03-03 19:28:42 -0800354###########################################################
355## Module installation rule
356###########################################################
357
Colin Cross744d33b2016-07-14 16:02:57 -0700358my_init_rc_installed :=
359my_init_rc_pairs :=
360my_installed_symlinks :=
Ying Wanged0361f2015-04-19 09:55:39 -0700361ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
Ying Wange56605a2013-02-06 11:44:41 -0800362$(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD)
Dan Willemsen7f016152016-02-29 17:52:39 -0800363$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800364 @echo "Install: $@"
Ying Wang84ed6fa2011-01-18 17:21:20 -0800365 $(copy-file-to-new-target)
Ying Wange56605a2013-02-06 11:44:41 -0800366 $(PRIVATE_POST_INSTALL_CMD)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800367
Dan Willemsen435360a2016-07-27 22:52:42 -0700368ifndef LOCAL_IS_HOST_MODULE
Ying Wang9fe15ac2015-08-20 12:02:10 -0700369# Rule to install the module's companion init.rc.
Dan Willemsen435360a2016-07-27 22:52:42 -0700370my_init_rc := $(LOCAL_INIT_RC_$(my_32_64_bit_suffix)) $(LOCAL_INIT_RC)
371ifneq ($(strip $(my_init_rc)),)
372my_init_rc_pairs := $(foreach rc,$(my_init_rc),$(LOCAL_PATH)/$(rc):$(TARGET_OUT$(partition_tag)_ETC)/init/$(notdir $(rc)))
373my_init_rc_installed := $(foreach rc,$(my_init_rc_pairs),$(call word-colon,2,$(rc)))
374
375# Make sure we only set up the copy rules once, even if another arch variant
376# shares a common LOCAL_INIT_RC.
377my_init_rc_new_pairs := $(filter-out $(ALL_INIT_RC_INSTALLED_PAIRS),$(my_init_rc_pairs))
378my_init_rc_new_installed := $(call copy-many-files,$(my_init_rc_new_pairs))
379ALL_INIT_RC_INSTALLED_PAIRS += $(my_init_rc_new_pairs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800380
Colin Crossaaf888a2016-09-07 12:48:30 -0700381$(my_all_targets) : $(my_init_rc_installed)
Dan Willemsen435360a2016-07-27 22:52:42 -0700382endif # my_init_rc
383endif # !LOCAL_IS_HOST_MODULE
Colin Cross744d33b2016-07-14 16:02:57 -0700384
385# Rule to install the module's companion symlinks
386my_installed_symlinks := $(addprefix $(my_module_path)/,$(LOCAL_MODULE_SYMLINKS) $(LOCAL_MODULE_SYMLINKS_$(my_32_64_bit_suffix)))
387$(foreach symlink,$(my_installed_symlinks),\
388 $(call symlink-file,$(LOCAL_INSTALLED_MODULE),$(my_installed_module_stem),$(symlink)))
389
Colin Crossaaf888a2016-09-07 12:48:30 -0700390$(my_all_targets) : | $(my_installed_symlinks)
Colin Cross6d34b612016-08-24 15:20:23 -0700391
Ying Wang9fe15ac2015-08-20 12:02:10 -0700392endif # !LOCAL_UNINSTALLABLE_MODULE
Joe Onoratoe334d252009-07-17 15:33:40 -0400393
394###########################################################
395## CHECK_BUILD goals
396###########################################################
Ying Wang6c1d1cc2014-09-29 14:34:32 -0700397my_checked_module :=
Joe Onoratoe334d252009-07-17 15:33:40 -0400398# If nobody has defined a more specific module for the
Ying Wang5a8d3452013-01-30 14:43:05 -0800399# checked modules, use LOCAL_BUILT_MODULE.
Ying Wang6c1d1cc2014-09-29 14:34:32 -0700400ifdef LOCAL_CHECKED_MODULE
401 my_checked_module := $(LOCAL_CHECKED_MODULE)
402else
403 my_checked_module := $(LOCAL_BUILT_MODULE)
Joe Onoratoe334d252009-07-17 15:33:40 -0400404endif
405
406# If they request that this module not be checked, then don't.
407# PLEASE DON'T SET THIS. ANY PLACES THAT SET THIS WITHOUT
408# GOOD REASON WILL HAVE IT REMOVED.
409ifdef LOCAL_DONT_CHECK_MODULE
Ying Wang6c1d1cc2014-09-29 14:34:32 -0700410 my_checked_module :=
Joe Onoratoe334d252009-07-17 15:33:40 -0400411endif
Ying Wang966c1e02014-05-20 14:43:51 -0700412# Don't check build target module defined for the 2nd arch
413ifndef LOCAL_IS_HOST_MODULE
Ying Wang6ef65192014-01-15 16:02:16 -0800414ifdef LOCAL_2ND_ARCH_VAR_PREFIX
Ying Wang6c1d1cc2014-09-29 14:34:32 -0700415 my_checked_module :=
Ying Wang6ef65192014-01-15 16:02:16 -0800416endif
Ying Wang966c1e02014-05-20 14:43:51 -0700417endif
Joe Onoratoe334d252009-07-17 15:33:40 -0400418
The Android Open Source Project88b60792009-03-03 19:28:42 -0800419###########################################################
Simran Basi6bea37c2017-02-16 18:04:10 -0800420## Compatibility suite files.
Ying Wang16243612015-06-03 12:43:50 -0700421###########################################################
422ifdef LOCAL_COMPATIBILITY_SUITE
Simran Basi3fb354c2017-02-08 15:53:32 -0800423
Ying Wang719f1982015-10-20 18:18:40 -0700424# The module itself.
Simran Basi6bea37c2017-02-16 18:04:10 -0800425$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
426 $(eval my_compat_dist_$(suite) := $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
427 $(LOCAL_BUILT_MODULE):$(dir)/$(my_installed_module_stem))))
Ying Wang719f1982015-10-20 18:18:40 -0700428
429# Make sure we only add the files once for multilib modules.
430ifndef $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files
431$(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files := true
432
Ying Wang25e01172015-09-17 12:24:56 -0700433# LOCAL_COMPATIBILITY_SUPPORT_FILES is a list of <src>[:<dest>].
Simran Basi6bea37c2017-02-16 18:04:10 -0800434$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
435 $(eval my_compat_dist_$(suite) += $(foreach f, $(LOCAL_COMPATIBILITY_SUPPORT_FILES), \
436 $(eval p := $(subst :,$(space),$(f))) \
437 $(eval s := $(word 1,$(p))) \
438 $(eval n := $(or $(word 2,$(p)),$(notdir $(word 1, $(p))))) \
439 $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
440 $(s):$(dir)/$(n)))))
441
Ying Wang16243612015-06-03 12:43:50 -0700442
Ying Wang25e01172015-09-17 12:24:56 -0700443ifneq (,$(wildcard $(LOCAL_PATH)/AndroidTest.xml))
Simran Basi6bea37c2017-02-16 18:04:10 -0800444$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
445 $(eval my_compat_dist_$(suite) += $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
446 $(LOCAL_PATH)/AndroidTest.xml:$(dir)/$(LOCAL_MODULE).config)))
Ying Wang562d7002015-06-04 11:21:49 -0700447endif
Ying Wang16243612015-06-03 12:43:50 -0700448
Ying Wang25e01172015-09-17 12:24:56 -0700449ifneq (,$(wildcard $(LOCAL_PATH)/DynamicConfig.xml))
Simran Basi6bea37c2017-02-16 18:04:10 -0800450$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
451 $(eval my_compat_dist_$(suite) += $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
452 $(LOCAL_PATH)/DynamicConfig.xml:$(dir)/$(LOCAL_MODULE).dynamic)))
Stuart Scott8fe4bc72015-08-18 14:31:08 -0700453endif
Ying Wang719f1982015-10-20 18:18:40 -0700454endif # $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files
Stuart Scott8fe4bc72015-08-18 14:31:08 -0700455
Simran Basi6bea37c2017-02-16 18:04:10 -0800456$(call create-suite-dependencies)
Ying Wang25e01172015-09-17 12:24:56 -0700457
Ying Wang16243612015-06-03 12:43:50 -0700458endif # LOCAL_COMPATIBILITY_SUITE
459
460###########################################################
Dan Willemsend07ba4e2016-12-09 16:05:09 -0800461## Test Data
462###########################################################
463my_test_data_pairs :=
464my_installed_test_data :=
465
466ifneq ($(filter NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
467ifneq ($(strip $(LOCAL_TEST_DATA)),)
468ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
469
470my_test_data_pairs := $(strip $(foreach td,$(LOCAL_TEST_DATA), \
471 $(eval _file := $(call word-colon,2,$(td))) \
472 $(if $(_file), \
473 $(eval _base := $(call word-colon,1,$(td))), \
474 $(eval _base := $(LOCAL_PATH)) \
475 $(eval _file := $(call word-colon,1,$(td)))) \
476 $(if $(findstring ..,$(_file)),$(error $(LOCAL_MODULE_MAKEFILE): LOCAL_TEST_DATA may not include '..': $(_file))) \
477 $(if $(filter /%,$(_base) $(_file)),$(error $(LOCAL_MODULE_MAKEFILE): LOCAL_TEST_DATA may not include absolute paths: $(_base) $(_file))) \
478 $(call append-path,$(_base),$(_file)):$(call append-path,$(my_module_path),$(_file))))
479
480my_installed_test_data := $(call copy-many-files,$(my_test_data_pairs))
481$(LOCAL_INSTALLED_MODULE): $(my_installed_test_data)
482
483endif
484endif
485endif
486
487###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800488## Register with ALL_MODULES
489###########################################################
490
Ying Wang6ef65192014-01-15 16:02:16 -0800491ALL_MODULES += $(my_register_name)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800492
493# Don't use += on subvars, or else they'll end up being
494# recursively expanded.
Ying Wang6ef65192014-01-15 16:02:16 -0800495ALL_MODULES.$(my_register_name).CLASS := \
496 $(ALL_MODULES.$(my_register_name).CLASS) $(LOCAL_MODULE_CLASS)
497ALL_MODULES.$(my_register_name).PATH := \
498 $(ALL_MODULES.$(my_register_name).PATH) $(LOCAL_PATH)
499ALL_MODULES.$(my_register_name).TAGS := \
Ying Wang37bd1f22014-01-27 15:19:09 -0800500 $(ALL_MODULES.$(my_register_name).TAGS) $(my_module_tags)
Ying Wang6ef65192014-01-15 16:02:16 -0800501ALL_MODULES.$(my_register_name).CHECKED := \
Ying Wang6c1d1cc2014-09-29 14:34:32 -0700502 $(ALL_MODULES.$(my_register_name).CHECKED) $(my_checked_module)
Ying Wang6ef65192014-01-15 16:02:16 -0800503ALL_MODULES.$(my_register_name).BUILT := \
504 $(ALL_MODULES.$(my_register_name).BUILT) $(LOCAL_BUILT_MODULE)
Ying Wang3380d3a2014-05-19 13:03:36 -0700505ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
Ying Wang6ef65192014-01-15 16:02:16 -0800506ALL_MODULES.$(my_register_name).INSTALLED := \
Ying Wang9fe15ac2015-08-20 12:02:10 -0700507 $(strip $(ALL_MODULES.$(my_register_name).INSTALLED) \
Dan Willemsend07ba4e2016-12-09 16:05:09 -0800508 $(LOCAL_INSTALLED_MODULE) $(my_init_rc_installed) $(my_installed_symlinks) \
509 $(my_installed_test_data))
Ying Wang3380d3a2014-05-19 13:03:36 -0700510ALL_MODULES.$(my_register_name).BUILT_INSTALLED := \
Ying Wang9fe15ac2015-08-20 12:02:10 -0700511 $(strip $(ALL_MODULES.$(my_register_name).BUILT_INSTALLED) \
512 $(LOCAL_BUILT_MODULE):$(LOCAL_INSTALLED_MODULE) \
Dan Willemsend07ba4e2016-12-09 16:05:09 -0800513 $(my_init_rc_pairs) $(my_test_data_pairs))
Ying Wang3380d3a2014-05-19 13:03:36 -0700514endif
Ying Wang3b81aab2014-05-05 16:46:52 -0700515ifdef LOCAL_PICKUP_FILES
516# Files or directories ready to pick up by the build system
517# when $(LOCAL_BUILT_MODULE) is done.
518ALL_MODULES.$(my_register_name).PICKUP_FILES := \
519 $(ALL_MODULES.$(my_register_name).PICKUP_FILES) $(LOCAL_PICKUP_FILES)
520endif
Dan Willemsen7a549852015-08-13 17:51:40 -0700521my_required_modules := $(LOCAL_REQUIRED_MODULES) \
522 $(LOCAL_REQUIRED_MODULES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
523ifdef LOCAL_IS_HOST_MODULE
524my_required_modules += $(LOCAL_REQUIRED_MODULES_$($(my_prefix)OS))
525endif
Ying Wang6ef65192014-01-15 16:02:16 -0800526ALL_MODULES.$(my_register_name).REQUIRED := \
Dan Willemsen7a549852015-08-13 17:51:40 -0700527 $(strip $(ALL_MODULES.$(my_register_name).REQUIRED) $(my_required_modules))
Alex Deymo00dc6672017-01-05 08:54:46 -0800528ALL_MODULES.$(my_register_name).EXPLICITLY_REQUIRED := \
529 $(strip $(ALL_MODULES.$(my_register_name).EXPLICITLY_REQUIRED)\
530 $(my_required_modules))
Yasuhiro Matsudaff82e822015-09-04 16:23:49 +0900531ALL_MODULES.$(my_register_name).EVENT_LOG_TAGS := \
532 $(ALL_MODULES.$(my_register_name).EVENT_LOG_TAGS) $(event_log_tags)
Ying Wang6ef65192014-01-15 16:02:16 -0800533ALL_MODULES.$(my_register_name).MAKEFILE := \
534 $(ALL_MODULES.$(my_register_name).MAKEFILE) $(LOCAL_MODULE_MAKEFILE)
Ying Wangdbb31be2011-12-09 15:11:57 -0800535ifdef LOCAL_MODULE_OWNER
Ying Wang6ef65192014-01-15 16:02:16 -0800536ALL_MODULES.$(my_register_name).OWNER := \
537 $(sort $(ALL_MODULES.$(my_register_name).OWNER) $(LOCAL_MODULE_OWNER))
Ying Wangdbb31be2011-12-09 15:11:57 -0800538endif
Ying Wang14a6cbd2014-02-10 22:26:23 -0800539ifdef LOCAL_2ND_ARCH_VAR_PREFIX
540ALL_MODULES.$(my_register_name).FOR_2ND_ARCH := true
541endif
Dan Willemsen057aaea2015-08-14 12:59:50 -0700542ALL_MODULES.$(my_register_name).FOR_HOST_CROSS := $(my_host_cross)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800543
Ying Wang6ef65192014-01-15 16:02:16 -0800544INSTALLABLE_FILES.$(LOCAL_INSTALLED_MODULE).MODULE := $(my_register_name)
Joe Onorato8a06bac2010-05-21 14:29:29 -0700545
Ying Wang39b9b692015-05-07 12:08:53 -0700546##########################################################
547# Track module-level dependencies.
548# Use $(LOCAL_MODULE) instead of $(my_register_name) to ignore module's bitness.
549ALL_DEPS.MODULES := $(sort $(ALL_DEPS.MODULES) $(LOCAL_MODULE))
550ALL_DEPS.$(LOCAL_MODULE).ALL_DEPS := $(sort \
551 $(ALL_MODULES.$(LOCAL_MODULE).ALL_DEPS) \
552 $(LOCAL_STATIC_LIBRARIES) \
553 $(LOCAL_WHOLE_STATIC_LIBRARIES) \
554 $(LOCAL_SHARED_LIBRARIES) \
Dan Willemsen8dae49c2017-02-15 15:48:11 -0800555 $(LOCAL_HEADER_LIBRARIES) \
Ying Wang39b9b692015-05-07 12:08:53 -0700556 $(LOCAL_STATIC_JAVA_LIBRARIES) \
557 $(LOCAL_JAVA_LIBRARIES)\
558 $(LOCAL_JNI_SHARED_LIBRARIES))
559
560ALL_DEPS.$(LOCAL_MODULE).LICENSE := $(sort $(ALL_DEPS.$(LOCAL_MODULE).LICENSE) $(license_files))
561
The Android Open Source Project88b60792009-03-03 19:28:42 -0800562###########################################################
Ying Wang37bd1f22014-01-27 15:19:09 -0800563## Take care of my_module_tags
The Android Open Source Project88b60792009-03-03 19:28:42 -0800564###########################################################
565
566# Keep track of all the tags we've seen.
Ying Wang37bd1f22014-01-27 15:19:09 -0800567ALL_MODULE_TAGS := $(sort $(ALL_MODULE_TAGS) $(my_module_tags))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800568
The Android Open Source Project88b60792009-03-03 19:28:42 -0800569# Add this module name to the tag list of each specified tag.
Ying Wang37bd1f22014-01-27 15:19:09 -0800570$(foreach tag,$(my_module_tags),\
Ying Wang6ef65192014-01-15 16:02:16 -0800571 $(eval ALL_MODULE_NAME_TAGS.$(tag) += $(my_register_name)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800572
The Android Open Source Project88b60792009-03-03 19:28:42 -0800573###########################################################
Ying Wangef4d82f2013-01-29 16:59:18 -0800574## umbrella targets used to verify builds
575###########################################################
Ying Wangef4d82f2013-01-29 16:59:18 -0800576j_or_n :=
Dan Willemsen8dae49c2017-02-15 15:48:11 -0800577ifneq (,$(filter EXECUTABLES SHARED_LIBRARIES STATIC_LIBRARIES HEADER_LIBRARIES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)))
Ying Wangef4d82f2013-01-29 16:59:18 -0800578j_or_n := native
579else
580ifneq (,$(filter JAVA_LIBRARIES APPS,$(LOCAL_MODULE_CLASS)))
581j_or_n := java
Ying Wangef4d82f2013-01-29 16:59:18 -0800582endif
583endif
584ifdef LOCAL_IS_HOST_MODULE
585h_or_t := host
Colin Crossd76e2e62016-12-09 13:08:27 -0800586ifeq ($(my_host_cross),true)
587h_or_hc_or_t := host-cross
Ying Wangef4d82f2013-01-29 16:59:18 -0800588else
Colin Crossd76e2e62016-12-09 13:08:27 -0800589h_or_hc_or_t := host
590endif
591else
592h_or_hc_or_t := target
Ying Wangef4d82f2013-01-29 16:59:18 -0800593h_or_t := target
594endif
595
Colin Crossd76e2e62016-12-09 13:08:27 -0800596
Ying Wangef4d82f2013-01-29 16:59:18 -0800597ifdef j_or_n
Ying Wang6c1d1cc2014-09-29 14:34:32 -0700598$(j_or_n) $(h_or_t) $(j_or_n)-$(h_or_t) : $(my_checked_module)
Ying Wang37bd1f22014-01-27 15:19:09 -0800599ifneq (,$(filter $(my_module_tags),tests))
Ying Wang6c1d1cc2014-09-29 14:34:32 -0700600$(j_or_n)-$(h_or_t)-tests $(j_or_n)-tests $(h_or_t)-tests : $(my_checked_module)
Ying Wangef4d82f2013-01-29 16:59:18 -0800601endif
Colin Crossd76e2e62016-12-09 13:08:27 -0800602$(LOCAL_MODULE)-$(h_or_hc_or_t) : $(my_all_targets)
603ifeq ($(j_or_n),native)
604$(LOCAL_MODULE)-$(h_or_hc_or_t)$(my_32_64_bit_suffix) : $(my_all_targets)
605endif
Ying Wangef4d82f2013-01-29 16:59:18 -0800606endif
607
608###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800609## NOTICE files
610###########################################################
611
Ying Wang13d69502012-11-01 17:22:33 -0700612include $(BUILD_NOTICE_FILE)