blob: 1d3f57ed8615c3a0b96df3848afdafaa20ac00be [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
17# Users can define base-rules-hook in their buildspec.mk to perform
18# arbitrary operations as each module is included.
19ifdef base-rules-hook
20$(if $(base-rules-hook),)
21endif
22
23###########################################################
24## Common instructions for a generic module.
25###########################################################
26
27LOCAL_MODULE := $(strip $(LOCAL_MODULE))
28ifeq ($(LOCAL_MODULE),)
29 $(error $(LOCAL_PATH): LOCAL_MODULE is not defined)
30endif
31
32LOCAL_IS_HOST_MODULE := $(strip $(LOCAL_IS_HOST_MODULE))
33ifdef 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 Willemsen057aaea2015-08-14 12:59:50 -070037 ifeq ($(LOCAL_HOST_PREFIX),)
38 my_prefix := HOST_
39 else
40 my_prefix := $(LOCAL_HOST_PREFIX)
41 endif
Ying Wang13d69502012-11-01 17:22:33 -070042 my_host := host-
The Android Open Source Project88b60792009-03-03 19:28:42 -080043else
Ying Wang13d69502012-11-01 17:22:33 -070044 my_prefix := TARGET_
45 my_host :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080046endif
47
Dan Willemsen057aaea2015-08-14 12:59:50 -070048ifeq ($(my_prefix),HOST_CROSS_)
49 my_host_cross := true
50else
51 my_host_cross :=
52endif
53
Ying Wang37bd1f22014-01-27 15:19:09 -080054my_module_tags := $(LOCAL_MODULE_TAGS)
Dan Willemsen057aaea2015-08-14 12:59:50 -070055ifeq ($(my_host_cross),true)
56 my_module_tags :=
57endif
Ying Wang37bd1f22014-01-27 15:19:09 -080058
Colin Crossa4447e82015-09-28 16:26:00 -070059# Ninja has an implicit dependency on the command being run, and kati will
60# regenerate the ninja manifest if any read makefile changes, so there is no
61# need to have dependencies on makefiles.
62# This won't catch all the cases where LOCAL_ADDITIONAL_DEPENDENCIES contains
63# a .mk file, because a few users of LOCAL_ADDITIONAL_DEPENDENCIES don't include
64# base_rules.mk, but it will fix the most common ones.
65LOCAL_ADDITIONAL_DEPENDENCIES := $(filter-out %.mk,$(LOCAL_ADDITIONAL_DEPENDENCIES))
Colin Crossa4447e82015-09-28 16:26:00 -070066
The Android Open Source Project88b60792009-03-03 19:28:42 -080067###########################################################
68## Validate and define fallbacks for input LOCAL_* variables.
69###########################################################
70
71## Dump a .csv file of all modules and their tags
72#ifneq ($(tag-list-first-time),false)
73#$(shell rm -f tag-list.csv)
74#tag-list-first-time := false
75#endif
Ying Wang37bd1f22014-01-27 15:19:09 -080076#$(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 -080077
Ying Wang6e371e42012-05-15 14:31:26 -070078LOCAL_UNINSTALLABLE_MODULE := $(strip $(LOCAL_UNINSTALLABLE_MODULE))
Ying Wang37bd1f22014-01-27 15:19:09 -080079my_module_tags := $(sort $(my_module_tags))
80ifeq (,$(my_module_tags))
81 my_module_tags := optional
Ying Wang2fd81cf2010-12-10 11:17:28 -080082endif
Joe Onorato918ee312012-05-18 20:43:14 -070083
Joe Onorato6a185e42012-05-22 14:08:50 -070084# User tags are not allowed anymore. Fail early because it will not be installed
85# like it used to be.
Ying Wang37bd1f22014-01-27 15:19:09 -080086ifneq ($(filter $(my_module_tags),user),)
Joe Onorato6a185e42012-05-22 14:08:50 -070087 $(warning *** Module name: $(LOCAL_MODULE))
88 $(warning *** Makefile location: $(LOCAL_MODULE_MAKEFILE))
89 $(warning * )
90 $(warning * Module is attempting to use the 'user' tag. This)
91 $(warning * used to cause the module to be installed automatically.)
92 $(warning * Now, the module must be listed in the PRODUCT_PACKAGES)
93 $(warning * section of a product makefile to have it installed.)
94 $(warning * )
95 $(error user tag detected on module.)
96endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080097
Jean-Baptiste Querua831cbd2010-01-07 11:06:50 -080098# Only the tags mentioned in this test are expected to be set by module
99# makefiles. Anything else is either a typo or a source of unexpected
100# behaviors.
Ying Wang37bd1f22014-01-27 15:19:09 -0800101ifneq ($(filter-out debug eng tests optional samples,$(my_module_tags)),)
102$(warning unusual tags $(my_module_tags) on $(LOCAL_MODULE) at $(LOCAL_PATH))
Jean-Baptiste Querua831cbd2010-01-07 11:06:50 -0800103endif
104
The Android Open Source Project88b60792009-03-03 19:28:42 -0800105# Add implicit tags.
106#
107# If the local directory or one of its parents contains a MODULE_LICENSE_GPL
Andrew Boie08a943b2013-12-10 13:52:00 -0800108# file, tag the module as "gnu". Search for "*_GPL*", "*_LGPL*" and "*_MPL*"
109# so that we can also find files like MODULE_LICENSE_GPL_AND_AFL
The Android Open Source Project88b60792009-03-03 19:28:42 -0800110#
Ying Wang39b9b692015-05-07 12:08:53 -0700111license_files := $(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*)
Andrew Boie08a943b2013-12-10 13:52:00 -0800112gpl_license_file := $(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*_GPL* MODULE_LICENSE*_MPL* MODULE_LICENSE*_LGPL*)
Ying Wangfd626f22011-12-12 12:57:38 -0800113ifneq ($(gpl_license_file),)
Ying Wang37bd1f22014-01-27 15:19:09 -0800114 my_module_tags += gnu
Ying Wangfd626f22011-12-12 12:57:38 -0800115 ALL_GPL_MODULE_LICENSE_FILES := $(sort $(ALL_GPL_MODULE_LICENSE_FILES) $(gpl_license_file))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800116endif
117
The Android Open Source Project88b60792009-03-03 19:28:42 -0800118LOCAL_MODULE_CLASS := $(strip $(LOCAL_MODULE_CLASS))
119ifneq ($(words $(LOCAL_MODULE_CLASS)),1)
120 $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS must contain exactly one word, not "$(LOCAL_MODULE_CLASS)")
121endif
122
Ying Wang6feb6d52014-04-17 10:03:35 -0700123my_32_64_bit_suffix := $(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT),64,32)
Colin Cross87974052014-03-21 12:25:44 -0700124
Ying Wang6e371e42012-05-15 14:31:26 -0700125ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
Colin Cross87974052014-03-21 12:25:44 -0700126my_multilib_module_path := $(strip $(LOCAL_MODULE_PATH_$(my_32_64_bit_suffix)))
Colin Cross87974052014-03-21 12:25:44 -0700127ifdef my_multilib_module_path
128my_module_path := $(my_multilib_module_path)
129else
Ying Wangb8e01852014-01-23 15:09:04 -0800130my_module_path := $(strip $(LOCAL_MODULE_PATH))
Colin Cross87974052014-03-21 12:25:44 -0700131endif
Colin Cross639c3362014-01-24 19:23:40 -0800132my_module_relative_path := $(strip $(LOCAL_MODULE_RELATIVE_PATH))
Ying Wangb8e01852014-01-23 15:09:04 -0800133ifeq ($(my_module_path),)
Ying Wang5338fbf2013-05-08 15:49:08 -0700134 ifdef LOCAL_IS_HOST_MODULE
135 partition_tag :=
136 else
137 ifeq (true,$(LOCAL_PROPRIETARY_MODULE))
138 partition_tag := _VENDOR
Ying Wangb8888432014-03-11 17:13:27 -0700139 else ifeq (true,$(LOCAL_OEM_MODULE))
140 partition_tag := _OEM
Ying Wang4540a852015-03-12 18:30:39 -0700141 else ifeq (true,$(LOCAL_ODM_MODULE))
142 partition_tag := _ODM
Ying Wang5338fbf2013-05-08 15:49:08 -0700143 else
144 # The definition of should-install-to-system will be different depending
145 # on which goal (e.g., sdk or just droid) is being built.
Ying Wang37bd1f22014-01-27 15:19:09 -0800146 partition_tag := $(if $(call should-install-to-system,$(my_module_tags)),,_DATA)
Ying Wang5338fbf2013-05-08 15:49:08 -0700147 endif
148 endif
Ying Wang6ef65192014-01-15 16:02:16 -0800149 install_path_var := $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT$(partition_tag)_$(LOCAL_MODULE_CLASS)
Ying Wang5338fbf2013-05-08 15:49:08 -0700150 ifeq (true,$(LOCAL_PRIVILEGED_MODULE))
151 install_path_var := $(install_path_var)_PRIVILEGED
152 endif
153
Colin Crossb34911c2014-01-22 17:34:28 -0800154 my_module_path := $($(install_path_var))
Ying Wangb8e01852014-01-23 15:09:04 -0800155 ifeq ($(strip $(my_module_path)),)
156 $(error $(LOCAL_PATH): unhandled install path "$(install_path_var) for $(LOCAL_MODULE)")
The Android Open Source Project88b60792009-03-03 19:28:42 -0800157 endif
158endif
Colin Cross639c3362014-01-24 19:23:40 -0800159ifneq ($(my_module_relative_path),)
160 my_module_path := $(my_module_path)/$(my_module_relative_path)
161endif
Ying Wang6e371e42012-05-15 14:31:26 -0700162endif # not LOCAL_UNINSTALLABLE_MODULE
The Android Open Source Project88b60792009-03-03 19:28:42 -0800163
164ifneq ($(strip $(LOCAL_BUILT_MODULE)$(LOCAL_INSTALLED_MODULE)),)
165 $(error $(LOCAL_PATH): LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE must not be defined by component makefiles)
166endif
167
Ying Wang6ef65192014-01-15 16:02:16 -0800168my_register_name := $(LOCAL_MODULE)
Dan Willemsen057aaea2015-08-14 12:59:50 -0700169ifeq ($(my_host_cross),true)
170 my_register_name := host_cross_$(LOCAL_MODULE)
171endif
Dan Willemsen9ecbf832016-02-05 16:20:19 -0800172ifdef LOCAL_2ND_ARCH_VAR_PREFIX
173ifndef LOCAL_NO_2ND_ARCH_MODULE_SUFFIX
174my_register_name := $(my_register_name)$($(my_prefix)2ND_ARCH_MODULE_SUFFIX)
175endif
176endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800177# Make sure that this IS_HOST/CLASS/MODULE combination is unique.
178module_id := MODULE.$(if \
Dan Willemsen057aaea2015-08-14 12:59:50 -0700179 $(LOCAL_IS_HOST_MODULE),$($(my_prefix)OS),TARGET).$(LOCAL_MODULE_CLASS).$(my_register_name)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800180ifdef $(module_id)
181$(error $(LOCAL_PATH): $(module_id) already defined by $($(module_id)))
182endif
183$(module_id) := $(LOCAL_PATH)
184
Dan Willemsen057aaea2015-08-14 12:59:50 -0700185intermediates := $(call local-intermediates-dir,,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800186intermediates.COMMON := $(call local-intermediates-dir,COMMON)
Colin Crossd8262642014-01-24 23:17:21 -0800187generated_sources_dir := $(call local-generated-sources-dir)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800188
189###########################################################
190# Pick a name for the intermediate and final targets
191###########################################################
Colin Cross5a9db902014-03-21 12:27:37 -0700192include $(BUILD_SYSTEM)/configure_module_stem.mk
The Android Open Source Project88b60792009-03-03 19:28:42 -0800193
194# OVERRIDE_BUILT_MODULE_PATH is only allowed to be used by the
195# internal SHARED_LIBRARIES build files.
196OVERRIDE_BUILT_MODULE_PATH := $(strip $(OVERRIDE_BUILT_MODULE_PATH))
197ifdef OVERRIDE_BUILT_MODULE_PATH
198 ifneq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
199 $(error $(LOCAL_PATH): Illegal use of OVERRIDE_BUILT_MODULE_PATH)
200 endif
201 built_module_path := $(OVERRIDE_BUILT_MODULE_PATH)
202else
203 built_module_path := $(intermediates)
204endif
Ying Wang966c1e02014-05-20 14:43:51 -0700205LOCAL_BUILT_MODULE := $(built_module_path)/$(my_built_module_stem)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800206
Ying Wang162991b2011-09-07 10:21:42 -0700207ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
Ying Wangaf9757e2014-07-17 21:24:42 -0700208 # Apk and its attachments reside in its own subdir.
209 ifeq ($(LOCAL_MODULE_CLASS),APPS)
210 # framework-res.apk doesn't like the additional layer.
211 ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
212 my_module_path := $(my_module_path)/$(LOCAL_MODULE)
213 endif
214 endif
Ying Wang966c1e02014-05-20 14:43:51 -0700215 LOCAL_INSTALLED_MODULE := $(my_module_path)/$(my_installed_module_stem)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800216endif
217
218# Assemble the list of targets to create PRIVATE_ variables for.
219LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE)
220
Yasuhiro Matsudaff82e822015-09-04 16:23:49 +0900221###########################################################
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +0900222## Create .toc files from shared objects to reduce unnecessary rebuild
223# .toc files have the list of external dynamic symbols without their addresses.
Shinichiro Hamaji89b255a2015-11-09 16:47:42 +0900224# As .KATI_RESTAT is specified to .toc files and commit-change-for-toc is used,
225# dependent binaries of a .toc file will be rebuilt only when the content of
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +0900226# the .toc file is changed.
227###########################################################
Ying Wangc01f2dc2015-12-15 10:00:19 -0800228ifndef LOCAL_IS_HOST_MODULE
229# Disable .toc optimization for host modules: we may run the host binaries during the build process
230# and the libraries' implementation matters.
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +0900231ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
232LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE).toc
233$(LOCAL_BUILT_MODULE).toc: $(LOCAL_BUILT_MODULE)
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +0900234 $(call $(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)transform-shared-lib-to-toc,$<,$@.tmp)
Shinichiro Hamaji89b255a2015-11-09 16:47:42 +0900235 $(call commit-change-for-toc,$@)
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +0900236
237# Kati adds restat=1 to ninja. GNU make does nothing for this.
238.KATI_RESTAT: $(LOCAL_BUILT_MODULE).toc
Colin Crosse2b8f682016-02-04 13:28:04 -0800239# Build .toc file when using mm, mma, or make $(my_register_name)
240$(my_register_name): $(LOCAL_BUILT_MODULE).toc
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +0900241endif
Ying Wangc01f2dc2015-12-15 10:00:19 -0800242endif
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +0900243
244###########################################################
Yasuhiro Matsudaff82e822015-09-04 16:23:49 +0900245## logtags: Add .logtags files to global list
246###########################################################
247
248logtags_sources := $(filter %.logtags,$(LOCAL_SRC_FILES))
249
250ifneq ($(strip $(logtags_sources)),)
251event_log_tags := $(addprefix $(LOCAL_PATH)/,$(logtags_sources))
252else
253event_log_tags :=
254endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800255
256###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800257## make clean- targets
258###########################################################
Ying Wang6ef65192014-01-15 16:02:16 -0800259cleantarget := clean-$(my_register_name)
260$(cleantarget) : PRIVATE_MODULE := $(my_register_name)
Ying Wang4d063412013-03-22 18:52:57 -0700261$(cleantarget) : PRIVATE_CLEAN_FILES := \
Ying Wang95221ca2012-11-07 14:07:34 -0800262 $(LOCAL_BUILT_MODULE) \
263 $(LOCAL_INSTALLED_MODULE) \
264 $(intermediates)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800265$(cleantarget)::
266 @echo "Clean: $(PRIVATE_MODULE)"
267 $(hide) rm -rf $(PRIVATE_CLEAN_FILES)
268
269###########################################################
270## Common definitions for module.
271###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800272$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PATH:=$(LOCAL_PATH)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800273$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_IS_HOST_MODULE := $(LOCAL_IS_HOST_MODULE)
274$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_HOST:= $(my_host)
Dan Willemsen057aaea2015-08-14 12:59:50 -0700275$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PREFIX := $(my_prefix)
276
Dima Zavin46e9bec2009-05-27 19:41:07 -0700277$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_INTERMEDIATES_DIR:= $(intermediates)
Ying Wang6feb6d52014-04-17 10:03:35 -0700278$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_2ND_ARCH_VAR_PREFIX := $(LOCAL_2ND_ARCH_VAR_PREFIX)
279
The Android Open Source Project88b60792009-03-03 19:28:42 -0800280# Tell the module and all of its sub-modules who it is.
Ying Wang6ef65192014-01-15 16:02:16 -0800281$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MODULE:= $(my_register_name)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800282
283# Provide a short-hand for building this module.
284# We name both BUILT and INSTALLED in case
285# LOCAL_UNINSTALLABLE_MODULE is set.
Ying Wang6ef65192014-01-15 16:02:16 -0800286.PHONY: $(my_register_name)
287$(my_register_name): $(LOCAL_BUILT_MODULE) $(LOCAL_INSTALLED_MODULE)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800288
Ying Wangcaeaa082015-09-23 16:08:55 -0700289# Set up phony targets that covers all modules under the given paths.
290# This allows us to build everything in given paths by running mmma/mma.
291my_path_components := $(subst /,$(space),$(LOCAL_PATH))
292my_path_prefix := MODULES-IN
293$(foreach c, $(my_path_components),\
Ying Wang61cd8842015-09-24 16:19:19 -0700294 $(eval my_path_prefix := $(my_path_prefix)-$(c))\
Ying Wangcaeaa082015-09-23 16:08:55 -0700295 $(eval .PHONY : $(my_path_prefix))\
296 $(eval $(my_path_prefix) : $(my_register_name)))
297
The Android Open Source Project88b60792009-03-03 19:28:42 -0800298###########################################################
299## Module installation rule
300###########################################################
301
302# Some hosts do not have ACP; override the LOCAL version if that's the case.
303ifneq ($(strip $(HOST_ACP_UNAVAILABLE)),)
304 LOCAL_ACP_UNAVAILABLE := $(strip $(HOST_ACP_UNAVAILABLE))
305endif
306
307ifndef LOCAL_UNINSTALLABLE_MODULE
308 # Define a copy rule to install the module.
309 # acp and libraries that it uses can't use acp for
310 # installation; hence, LOCAL_ACP_UNAVAILABLE.
Ying Wange56605a2013-02-06 11:44:41 -0800311$(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800312ifneq ($(LOCAL_ACP_UNAVAILABLE),true)
313$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE) | $(ACP)
314 @echo "Install: $@"
Ying Wang84ed6fa2011-01-18 17:21:20 -0800315 $(copy-file-to-new-target)
Ying Wange56605a2013-02-06 11:44:41 -0800316 $(PRIVATE_POST_INSTALL_CMD)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800317else
318$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE)
319 @echo "Install: $@"
320 $(copy-file-to-target-with-cp)
321endif
322
Ying Wang9fe15ac2015-08-20 12:02:10 -0700323# Rule to install the module's companion init.rc.
Ying Wang9fe15ac2015-08-20 12:02:10 -0700324my_init_rc_installed :=
Ying Wang41d66782016-02-24 17:34:52 -0800325my_init_rc_pairs :=
326my_init_rc := $(LOCAL_INIT_RC_$(my_32_64_bit_suffix))
327ifneq ($(my_init_rc),)
328my_init_rc_pairs += $(LOCAL_PATH)/$(my_init_rc):$(TARGET_OUT$(partition_tag)_ETC)/init/$(notdir $(my_init_rc))
329endif
330ifneq ($(LOCAL_INIT_RC),)
331my_init_rc_pairs += $(LOCAL_PATH)/$(LOCAL_INIT_RC):$(TARGET_OUT$(partition_tag)_ETC)/init/$(notdir $(LOCAL_INIT_RC))
Ying Wang9fe15ac2015-08-20 12:02:10 -0700332# Make sure we don't define the rule twice in multilib module.
333LOCAL_INIT_RC :=
334endif
Ying Wang41d66782016-02-24 17:34:52 -0800335ifneq ($(my_init_rc_pairs),)
336my_init_rc_installed := $(call copy-many-files,$(my_init_rc_pairs))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800337
Ying Wang9fe15ac2015-08-20 12:02:10 -0700338$(my_register_name) : $(my_init_rc_installed)
Ying Wang41d66782016-02-24 17:34:52 -0800339endif # my_init_rc_pairs
Ying Wang9fe15ac2015-08-20 12:02:10 -0700340endif # !LOCAL_UNINSTALLABLE_MODULE
Joe Onoratoe334d252009-07-17 15:33:40 -0400341
342###########################################################
343## CHECK_BUILD goals
344###########################################################
Ying Wang6c1d1cc2014-09-29 14:34:32 -0700345my_checked_module :=
Joe Onoratoe334d252009-07-17 15:33:40 -0400346# If nobody has defined a more specific module for the
Ying Wang5a8d3452013-01-30 14:43:05 -0800347# checked modules, use LOCAL_BUILT_MODULE.
Ying Wang6c1d1cc2014-09-29 14:34:32 -0700348ifdef LOCAL_CHECKED_MODULE
349 my_checked_module := $(LOCAL_CHECKED_MODULE)
350else
351 my_checked_module := $(LOCAL_BUILT_MODULE)
Joe Onoratoe334d252009-07-17 15:33:40 -0400352endif
353
354# If they request that this module not be checked, then don't.
355# PLEASE DON'T SET THIS. ANY PLACES THAT SET THIS WITHOUT
356# GOOD REASON WILL HAVE IT REMOVED.
357ifdef LOCAL_DONT_CHECK_MODULE
Ying Wang6c1d1cc2014-09-29 14:34:32 -0700358 my_checked_module :=
Joe Onoratoe334d252009-07-17 15:33:40 -0400359endif
Ying Wang966c1e02014-05-20 14:43:51 -0700360# Don't check build target module defined for the 2nd arch
361ifndef LOCAL_IS_HOST_MODULE
Ying Wang6ef65192014-01-15 16:02:16 -0800362ifdef LOCAL_2ND_ARCH_VAR_PREFIX
Ying Wang6c1d1cc2014-09-29 14:34:32 -0700363 my_checked_module :=
Ying Wang6ef65192014-01-15 16:02:16 -0800364endif
Ying Wang966c1e02014-05-20 14:43:51 -0700365endif
Joe Onoratoe334d252009-07-17 15:33:40 -0400366
The Android Open Source Project88b60792009-03-03 19:28:42 -0800367###########################################################
368## Register with ALL_MODULES
369###########################################################
370
Ying Wang6ef65192014-01-15 16:02:16 -0800371ALL_MODULES += $(my_register_name)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800372
373# Don't use += on subvars, or else they'll end up being
374# recursively expanded.
Ying Wang6ef65192014-01-15 16:02:16 -0800375ALL_MODULES.$(my_register_name).CLASS := \
376 $(ALL_MODULES.$(my_register_name).CLASS) $(LOCAL_MODULE_CLASS)
377ALL_MODULES.$(my_register_name).PATH := \
378 $(ALL_MODULES.$(my_register_name).PATH) $(LOCAL_PATH)
379ALL_MODULES.$(my_register_name).TAGS := \
Ying Wang37bd1f22014-01-27 15:19:09 -0800380 $(ALL_MODULES.$(my_register_name).TAGS) $(my_module_tags)
Ying Wang6ef65192014-01-15 16:02:16 -0800381ALL_MODULES.$(my_register_name).CHECKED := \
Ying Wang6c1d1cc2014-09-29 14:34:32 -0700382 $(ALL_MODULES.$(my_register_name).CHECKED) $(my_checked_module)
Ying Wang6ef65192014-01-15 16:02:16 -0800383ALL_MODULES.$(my_register_name).BUILT := \
384 $(ALL_MODULES.$(my_register_name).BUILT) $(LOCAL_BUILT_MODULE)
Ying Wang3380d3a2014-05-19 13:03:36 -0700385ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
Ying Wang6ef65192014-01-15 16:02:16 -0800386ALL_MODULES.$(my_register_name).INSTALLED := \
Ying Wang9fe15ac2015-08-20 12:02:10 -0700387 $(strip $(ALL_MODULES.$(my_register_name).INSTALLED) \
388 $(LOCAL_INSTALLED_MODULE) $(my_init_rc_installed))
Ying Wang3380d3a2014-05-19 13:03:36 -0700389ALL_MODULES.$(my_register_name).BUILT_INSTALLED := \
Ying Wang9fe15ac2015-08-20 12:02:10 -0700390 $(strip $(ALL_MODULES.$(my_register_name).BUILT_INSTALLED) \
391 $(LOCAL_BUILT_MODULE):$(LOCAL_INSTALLED_MODULE) \
Ying Wang41d66782016-02-24 17:34:52 -0800392 $(my_init_rc_pairs))
Ying Wang3380d3a2014-05-19 13:03:36 -0700393endif
Ying Wang3b81aab2014-05-05 16:46:52 -0700394ifdef LOCAL_PICKUP_FILES
395# Files or directories ready to pick up by the build system
396# when $(LOCAL_BUILT_MODULE) is done.
397ALL_MODULES.$(my_register_name).PICKUP_FILES := \
398 $(ALL_MODULES.$(my_register_name).PICKUP_FILES) $(LOCAL_PICKUP_FILES)
399endif
Dan Willemsen7a549852015-08-13 17:51:40 -0700400my_required_modules := $(LOCAL_REQUIRED_MODULES) \
401 $(LOCAL_REQUIRED_MODULES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
402ifdef LOCAL_IS_HOST_MODULE
403my_required_modules += $(LOCAL_REQUIRED_MODULES_$($(my_prefix)OS))
404endif
Ying Wang6ef65192014-01-15 16:02:16 -0800405ALL_MODULES.$(my_register_name).REQUIRED := \
Dan Willemsen7a549852015-08-13 17:51:40 -0700406 $(strip $(ALL_MODULES.$(my_register_name).REQUIRED) $(my_required_modules))
Yasuhiro Matsudaff82e822015-09-04 16:23:49 +0900407ALL_MODULES.$(my_register_name).EVENT_LOG_TAGS := \
408 $(ALL_MODULES.$(my_register_name).EVENT_LOG_TAGS) $(event_log_tags)
Ying Wang6ef65192014-01-15 16:02:16 -0800409ALL_MODULES.$(my_register_name).MAKEFILE := \
410 $(ALL_MODULES.$(my_register_name).MAKEFILE) $(LOCAL_MODULE_MAKEFILE)
Ying Wangdbb31be2011-12-09 15:11:57 -0800411ifdef LOCAL_MODULE_OWNER
Ying Wang6ef65192014-01-15 16:02:16 -0800412ALL_MODULES.$(my_register_name).OWNER := \
413 $(sort $(ALL_MODULES.$(my_register_name).OWNER) $(LOCAL_MODULE_OWNER))
Ying Wangdbb31be2011-12-09 15:11:57 -0800414endif
Ying Wang14a6cbd2014-02-10 22:26:23 -0800415ifdef LOCAL_2ND_ARCH_VAR_PREFIX
416ALL_MODULES.$(my_register_name).FOR_2ND_ARCH := true
417endif
Dan Willemsen057aaea2015-08-14 12:59:50 -0700418ALL_MODULES.$(my_register_name).FOR_HOST_CROSS := $(my_host_cross)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800419
Ying Wang6ef65192014-01-15 16:02:16 -0800420INSTALLABLE_FILES.$(LOCAL_INSTALLED_MODULE).MODULE := $(my_register_name)
Joe Onorato8a06bac2010-05-21 14:29:29 -0700421
Ying Wang39b9b692015-05-07 12:08:53 -0700422##########################################################
423# Track module-level dependencies.
424# Use $(LOCAL_MODULE) instead of $(my_register_name) to ignore module's bitness.
425ALL_DEPS.MODULES := $(sort $(ALL_DEPS.MODULES) $(LOCAL_MODULE))
426ALL_DEPS.$(LOCAL_MODULE).ALL_DEPS := $(sort \
427 $(ALL_MODULES.$(LOCAL_MODULE).ALL_DEPS) \
428 $(LOCAL_STATIC_LIBRARIES) \
429 $(LOCAL_WHOLE_STATIC_LIBRARIES) \
430 $(LOCAL_SHARED_LIBRARIES) \
431 $(LOCAL_STATIC_JAVA_LIBRARIES) \
432 $(LOCAL_JAVA_LIBRARIES)\
433 $(LOCAL_JNI_SHARED_LIBRARIES))
434
435ALL_DEPS.$(LOCAL_MODULE).LICENSE := $(sort $(ALL_DEPS.$(LOCAL_MODULE).LICENSE) $(license_files))
436
The Android Open Source Project88b60792009-03-03 19:28:42 -0800437###########################################################
Ying Wang37bd1f22014-01-27 15:19:09 -0800438## Take care of my_module_tags
The Android Open Source Project88b60792009-03-03 19:28:42 -0800439###########################################################
440
441# Keep track of all the tags we've seen.
Ying Wang37bd1f22014-01-27 15:19:09 -0800442ALL_MODULE_TAGS := $(sort $(ALL_MODULE_TAGS) $(my_module_tags))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800443
The Android Open Source Project88b60792009-03-03 19:28:42 -0800444# Add this module name to the tag list of each specified tag.
Ying Wang37bd1f22014-01-27 15:19:09 -0800445$(foreach tag,$(my_module_tags),\
Ying Wang6ef65192014-01-15 16:02:16 -0800446 $(eval ALL_MODULE_NAME_TAGS.$(tag) += $(my_register_name)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800447
The Android Open Source Project88b60792009-03-03 19:28:42 -0800448###########################################################
Ying Wangef4d82f2013-01-29 16:59:18 -0800449## umbrella targets used to verify builds
450###########################################################
Ying Wangef4d82f2013-01-29 16:59:18 -0800451j_or_n :=
452ifneq (,$(filter EXECUTABLES SHARED_LIBRARIES STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS)))
453j_or_n := native
454else
455ifneq (,$(filter JAVA_LIBRARIES APPS,$(LOCAL_MODULE_CLASS)))
456j_or_n := java
Ying Wangef4d82f2013-01-29 16:59:18 -0800457endif
458endif
459ifdef LOCAL_IS_HOST_MODULE
460h_or_t := host
461else
462h_or_t := target
463endif
464
465ifdef j_or_n
Ying Wang6c1d1cc2014-09-29 14:34:32 -0700466$(j_or_n) $(h_or_t) $(j_or_n)-$(h_or_t) : $(my_checked_module)
Ying Wang37bd1f22014-01-27 15:19:09 -0800467ifneq (,$(filter $(my_module_tags),tests))
Ying Wang6c1d1cc2014-09-29 14:34:32 -0700468$(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 -0800469endif
470endif
471
472###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800473## NOTICE files
474###########################################################
475
Ying Wang13d69502012-11-01 17:22:33 -0700476include $(BUILD_NOTICE_FILE)