blob: 6fc2935b2dcd547997f3aaaff6059a1e4cb33f5f [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 -070059ifdef BUILDING_WITH_NINJA
60# Ninja has an implicit dependency on the command being run, and kati will
61# regenerate the ninja manifest if any read makefile changes, so there is no
62# need to have dependencies on makefiles.
63# This won't catch all the cases where LOCAL_ADDITIONAL_DEPENDENCIES contains
64# a .mk file, because a few users of LOCAL_ADDITIONAL_DEPENDENCIES don't include
65# base_rules.mk, but it will fix the most common ones.
66LOCAL_ADDITIONAL_DEPENDENCIES := $(filter-out %.mk,$(LOCAL_ADDITIONAL_DEPENDENCIES))
67endif
68
The Android Open Source Project88b60792009-03-03 19:28:42 -080069###########################################################
70## Validate and define fallbacks for input LOCAL_* variables.
71###########################################################
72
73## Dump a .csv file of all modules and their tags
74#ifneq ($(tag-list-first-time),false)
75#$(shell rm -f tag-list.csv)
76#tag-list-first-time := false
77#endif
Ying Wang37bd1f22014-01-27 15:19:09 -080078#$(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 -080079
Ying Wang6e371e42012-05-15 14:31:26 -070080LOCAL_UNINSTALLABLE_MODULE := $(strip $(LOCAL_UNINSTALLABLE_MODULE))
Ying Wang37bd1f22014-01-27 15:19:09 -080081my_module_tags := $(sort $(my_module_tags))
82ifeq (,$(my_module_tags))
83 my_module_tags := optional
Ying Wang2fd81cf2010-12-10 11:17:28 -080084endif
Joe Onorato918ee312012-05-18 20:43:14 -070085
Joe Onorato6a185e42012-05-22 14:08:50 -070086# User tags are not allowed anymore. Fail early because it will not be installed
87# like it used to be.
Ying Wang37bd1f22014-01-27 15:19:09 -080088ifneq ($(filter $(my_module_tags),user),)
Joe Onorato6a185e42012-05-22 14:08:50 -070089 $(warning *** Module name: $(LOCAL_MODULE))
90 $(warning *** Makefile location: $(LOCAL_MODULE_MAKEFILE))
91 $(warning * )
92 $(warning * Module is attempting to use the 'user' tag. This)
93 $(warning * used to cause the module to be installed automatically.)
94 $(warning * Now, the module must be listed in the PRODUCT_PACKAGES)
95 $(warning * section of a product makefile to have it installed.)
96 $(warning * )
97 $(error user tag detected on module.)
98endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080099
Jean-Baptiste Querua831cbd2010-01-07 11:06:50 -0800100# Only the tags mentioned in this test are expected to be set by module
101# makefiles. Anything else is either a typo or a source of unexpected
102# behaviors.
Ying Wang37bd1f22014-01-27 15:19:09 -0800103ifneq ($(filter-out debug eng tests optional samples,$(my_module_tags)),)
104$(warning unusual tags $(my_module_tags) on $(LOCAL_MODULE) at $(LOCAL_PATH))
Jean-Baptiste Querua831cbd2010-01-07 11:06:50 -0800105endif
106
The Android Open Source Project88b60792009-03-03 19:28:42 -0800107# Add implicit tags.
108#
109# If the local directory or one of its parents contains a MODULE_LICENSE_GPL
Andrew Boie08a943b2013-12-10 13:52:00 -0800110# file, tag the module as "gnu". Search for "*_GPL*", "*_LGPL*" and "*_MPL*"
111# so that we can also find files like MODULE_LICENSE_GPL_AND_AFL
The Android Open Source Project88b60792009-03-03 19:28:42 -0800112#
Ying Wang39b9b692015-05-07 12:08:53 -0700113license_files := $(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*)
Andrew Boie08a943b2013-12-10 13:52:00 -0800114gpl_license_file := $(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*_GPL* MODULE_LICENSE*_MPL* MODULE_LICENSE*_LGPL*)
Ying Wangfd626f22011-12-12 12:57:38 -0800115ifneq ($(gpl_license_file),)
Ying Wang37bd1f22014-01-27 15:19:09 -0800116 my_module_tags += gnu
Ying Wangfd626f22011-12-12 12:57:38 -0800117 ALL_GPL_MODULE_LICENSE_FILES := $(sort $(ALL_GPL_MODULE_LICENSE_FILES) $(gpl_license_file))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800118endif
119
The Android Open Source Project88b60792009-03-03 19:28:42 -0800120LOCAL_MODULE_CLASS := $(strip $(LOCAL_MODULE_CLASS))
121ifneq ($(words $(LOCAL_MODULE_CLASS)),1)
122 $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS must contain exactly one word, not "$(LOCAL_MODULE_CLASS)")
123endif
124
Ying Wang6feb6d52014-04-17 10:03:35 -0700125my_32_64_bit_suffix := $(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT),64,32)
Colin Cross87974052014-03-21 12:25:44 -0700126
Ying Wang6e371e42012-05-15 14:31:26 -0700127ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
Colin Cross87974052014-03-21 12:25:44 -0700128my_multilib_module_path := $(strip $(LOCAL_MODULE_PATH_$(my_32_64_bit_suffix)))
Colin Cross87974052014-03-21 12:25:44 -0700129ifdef my_multilib_module_path
130my_module_path := $(my_multilib_module_path)
131else
Ying Wangb8e01852014-01-23 15:09:04 -0800132my_module_path := $(strip $(LOCAL_MODULE_PATH))
Colin Cross87974052014-03-21 12:25:44 -0700133endif
Colin Cross639c3362014-01-24 19:23:40 -0800134my_module_relative_path := $(strip $(LOCAL_MODULE_RELATIVE_PATH))
Ying Wangb8e01852014-01-23 15:09:04 -0800135ifeq ($(my_module_path),)
Ying Wang5338fbf2013-05-08 15:49:08 -0700136 ifdef LOCAL_IS_HOST_MODULE
137 partition_tag :=
138 else
139 ifeq (true,$(LOCAL_PROPRIETARY_MODULE))
140 partition_tag := _VENDOR
Ying Wangb8888432014-03-11 17:13:27 -0700141 else ifeq (true,$(LOCAL_OEM_MODULE))
142 partition_tag := _OEM
Ying Wang5fcf1092015-03-12 18:30:39 -0700143 else ifeq (true,$(LOCAL_ODM_MODULE))
144 partition_tag := _ODM
Ying Wang5338fbf2013-05-08 15:49:08 -0700145 else
146 # The definition of should-install-to-system will be different depending
147 # on which goal (e.g., sdk or just droid) is being built.
Ying Wang37bd1f22014-01-27 15:19:09 -0800148 partition_tag := $(if $(call should-install-to-system,$(my_module_tags)),,_DATA)
Ying Wang5338fbf2013-05-08 15:49:08 -0700149 endif
150 endif
Ying Wang6ef65192014-01-15 16:02:16 -0800151 install_path_var := $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT$(partition_tag)_$(LOCAL_MODULE_CLASS)
Ying Wang5338fbf2013-05-08 15:49:08 -0700152 ifeq (true,$(LOCAL_PRIVILEGED_MODULE))
153 install_path_var := $(install_path_var)_PRIVILEGED
154 endif
155
Colin Crossb34911c2014-01-22 17:34:28 -0800156 my_module_path := $($(install_path_var))
Ying Wangb8e01852014-01-23 15:09:04 -0800157 ifeq ($(strip $(my_module_path)),)
158 $(error $(LOCAL_PATH): unhandled install path "$(install_path_var) for $(LOCAL_MODULE)")
The Android Open Source Project88b60792009-03-03 19:28:42 -0800159 endif
160endif
Colin Cross639c3362014-01-24 19:23:40 -0800161ifneq ($(my_module_relative_path),)
162 my_module_path := $(my_module_path)/$(my_module_relative_path)
163endif
Ying Wang6e371e42012-05-15 14:31:26 -0700164endif # not LOCAL_UNINSTALLABLE_MODULE
The Android Open Source Project88b60792009-03-03 19:28:42 -0800165
166ifneq ($(strip $(LOCAL_BUILT_MODULE)$(LOCAL_INSTALLED_MODULE)),)
167 $(error $(LOCAL_PATH): LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE must not be defined by component makefiles)
168endif
169
Ying Wang6ef65192014-01-15 16:02:16 -0800170my_register_name := $(LOCAL_MODULE)
Dan Willemsen057aaea2015-08-14 12:59:50 -0700171ifeq ($(my_host_cross),true)
172 my_register_name := host_cross_$(LOCAL_MODULE)
173endif
Dan Willemsen7e57b8c2016-02-05 16:20:19 -0800174ifdef LOCAL_2ND_ARCH_VAR_PREFIX
175ifndef LOCAL_NO_2ND_ARCH_MODULE_SUFFIX
176my_register_name := $(my_register_name)$($(my_prefix)2ND_ARCH_MODULE_SUFFIX)
177endif
178endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800179# Make sure that this IS_HOST/CLASS/MODULE combination is unique.
180module_id := MODULE.$(if \
Dan Willemsen057aaea2015-08-14 12:59:50 -0700181 $(LOCAL_IS_HOST_MODULE),$($(my_prefix)OS),TARGET).$(LOCAL_MODULE_CLASS).$(my_register_name)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800182ifdef $(module_id)
183$(error $(LOCAL_PATH): $(module_id) already defined by $($(module_id)))
184endif
185$(module_id) := $(LOCAL_PATH)
186
Dan Willemsen057aaea2015-08-14 12:59:50 -0700187intermediates := $(call local-intermediates-dir,,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800188intermediates.COMMON := $(call local-intermediates-dir,COMMON)
Colin Crossd8262642014-01-24 23:17:21 -0800189generated_sources_dir := $(call local-generated-sources-dir)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800190
191###########################################################
192# Pick a name for the intermediate and final targets
193###########################################################
Colin Cross5a9db902014-03-21 12:27:37 -0700194include $(BUILD_SYSTEM)/configure_module_stem.mk
The Android Open Source Project88b60792009-03-03 19:28:42 -0800195
196# OVERRIDE_BUILT_MODULE_PATH is only allowed to be used by the
197# internal SHARED_LIBRARIES build files.
198OVERRIDE_BUILT_MODULE_PATH := $(strip $(OVERRIDE_BUILT_MODULE_PATH))
199ifdef OVERRIDE_BUILT_MODULE_PATH
200 ifneq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
201 $(error $(LOCAL_PATH): Illegal use of OVERRIDE_BUILT_MODULE_PATH)
202 endif
203 built_module_path := $(OVERRIDE_BUILT_MODULE_PATH)
204else
205 built_module_path := $(intermediates)
206endif
Ying Wang966c1e02014-05-20 14:43:51 -0700207LOCAL_BUILT_MODULE := $(built_module_path)/$(my_built_module_stem)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800208
Ying Wang162991b2011-09-07 10:21:42 -0700209ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
Ying Wangaf9757e2014-07-17 21:24:42 -0700210 # Apk and its attachments reside in its own subdir.
211 ifeq ($(LOCAL_MODULE_CLASS),APPS)
212 # framework-res.apk doesn't like the additional layer.
Jakub Adameka08a1012016-10-03 09:56:16 +0100213 ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
214 # Neither do Runtime Resource Overlay apks, which contain just the overlaid resources.
215 else ifeq ($(LOCAL_IS_RUNTIME_RESOURCE_OVERLAY),true)
216 else
Ying Wangaf9757e2014-07-17 21:24:42 -0700217 my_module_path := $(my_module_path)/$(LOCAL_MODULE)
218 endif
219 endif
Ying Wang966c1e02014-05-20 14:43:51 -0700220 LOCAL_INSTALLED_MODULE := $(my_module_path)/$(my_installed_module_stem)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800221endif
222
223# Assemble the list of targets to create PRIVATE_ variables for.
224LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE)
225
Yasuhiro Matsudaff82e822015-09-04 16:23:49 +0900226###########################################################
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +0900227## Create .toc files from shared objects to reduce unnecessary rebuild
228# .toc files have the list of external dynamic symbols without their addresses.
Shinichiro Hamaji89b255a2015-11-09 16:47:42 +0900229# As .KATI_RESTAT is specified to .toc files and commit-change-for-toc is used,
230# dependent binaries of a .toc file will be rebuilt only when the content of
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +0900231# the .toc file is changed.
232###########################################################
Ying Wangc01f2dc2015-12-15 10:00:19 -0800233ifndef LOCAL_IS_HOST_MODULE
234# Disable .toc optimization for host modules: we may run the host binaries during the build process
235# and the libraries' implementation matters.
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +0900236ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
237LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE).toc
238$(LOCAL_BUILT_MODULE).toc: $(LOCAL_BUILT_MODULE)
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +0900239 $(call $(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)transform-shared-lib-to-toc,$<,$@.tmp)
Shinichiro Hamaji89b255a2015-11-09 16:47:42 +0900240 $(call commit-change-for-toc,$@)
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +0900241
242# Kati adds restat=1 to ninja. GNU make does nothing for this.
243.KATI_RESTAT: $(LOCAL_BUILT_MODULE).toc
Colin Crosse2b8f682016-02-04 13:28:04 -0800244# Build .toc file when using mm, mma, or make $(my_register_name)
245$(my_register_name): $(LOCAL_BUILT_MODULE).toc
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +0900246endif
Ying Wangc01f2dc2015-12-15 10:00:19 -0800247endif
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +0900248
249###########################################################
Yasuhiro Matsudaff82e822015-09-04 16:23:49 +0900250## logtags: Add .logtags files to global list
251###########################################################
252
253logtags_sources := $(filter %.logtags,$(LOCAL_SRC_FILES))
254
255ifneq ($(strip $(logtags_sources)),)
256event_log_tags := $(addprefix $(LOCAL_PATH)/,$(logtags_sources))
257else
258event_log_tags :=
259endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800260
261###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800262## make clean- targets
263###########################################################
Ying Wang6ef65192014-01-15 16:02:16 -0800264cleantarget := clean-$(my_register_name)
265$(cleantarget) : PRIVATE_MODULE := $(my_register_name)
Ying Wang4d063412013-03-22 18:52:57 -0700266$(cleantarget) : PRIVATE_CLEAN_FILES := \
Ying Wang95221ca2012-11-07 14:07:34 -0800267 $(LOCAL_BUILT_MODULE) \
268 $(LOCAL_INSTALLED_MODULE) \
269 $(intermediates)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800270$(cleantarget)::
271 @echo "Clean: $(PRIVATE_MODULE)"
272 $(hide) rm -rf $(PRIVATE_CLEAN_FILES)
273
274###########################################################
275## Common definitions for module.
276###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800277$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PATH:=$(LOCAL_PATH)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800278$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_IS_HOST_MODULE := $(LOCAL_IS_HOST_MODULE)
279$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_HOST:= $(my_host)
Dan Willemsen057aaea2015-08-14 12:59:50 -0700280$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PREFIX := $(my_prefix)
281
Dima Zavin46e9bec2009-05-27 19:41:07 -0700282$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_INTERMEDIATES_DIR:= $(intermediates)
Ying Wang6feb6d52014-04-17 10:03:35 -0700283$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_2ND_ARCH_VAR_PREFIX := $(LOCAL_2ND_ARCH_VAR_PREFIX)
284
The Android Open Source Project88b60792009-03-03 19:28:42 -0800285# Tell the module and all of its sub-modules who it is.
Ying Wang6ef65192014-01-15 16:02:16 -0800286$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MODULE:= $(my_register_name)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800287
288# Provide a short-hand for building this module.
289# We name both BUILT and INSTALLED in case
290# LOCAL_UNINSTALLABLE_MODULE is set.
Ying Wang6ef65192014-01-15 16:02:16 -0800291.PHONY: $(my_register_name)
292$(my_register_name): $(LOCAL_BUILT_MODULE) $(LOCAL_INSTALLED_MODULE)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800293
Ying Wangcaeaa082015-09-23 16:08:55 -0700294# Set up phony targets that covers all modules under the given paths.
295# This allows us to build everything in given paths by running mmma/mma.
296my_path_components := $(subst /,$(space),$(LOCAL_PATH))
297my_path_prefix := MODULES-IN
298$(foreach c, $(my_path_components),\
Ying Wang61cd8842015-09-24 16:19:19 -0700299 $(eval my_path_prefix := $(my_path_prefix)-$(c))\
Ying Wangcaeaa082015-09-23 16:08:55 -0700300 $(eval .PHONY : $(my_path_prefix))\
301 $(eval $(my_path_prefix) : $(my_register_name)))
302
The Android Open Source Project88b60792009-03-03 19:28:42 -0800303###########################################################
304## Module installation rule
305###########################################################
306
307# Some hosts do not have ACP; override the LOCAL version if that's the case.
308ifneq ($(strip $(HOST_ACP_UNAVAILABLE)),)
309 LOCAL_ACP_UNAVAILABLE := $(strip $(HOST_ACP_UNAVAILABLE))
310endif
311
Ying Wanged0361f2015-04-19 09:55:39 -0700312ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800313 # Define a copy rule to install the module.
314 # acp and libraries that it uses can't use acp for
315 # installation; hence, LOCAL_ACP_UNAVAILABLE.
Ying Wange56605a2013-02-06 11:44:41 -0800316$(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800317ifneq ($(LOCAL_ACP_UNAVAILABLE),true)
318$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE) | $(ACP)
319 @echo "Install: $@"
Ying Wang84ed6fa2011-01-18 17:21:20 -0800320 $(copy-file-to-new-target)
Ying Wange56605a2013-02-06 11:44:41 -0800321 $(PRIVATE_POST_INSTALL_CMD)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800322else
323$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE)
324 @echo "Install: $@"
325 $(copy-file-to-target-with-cp)
326endif
327
Ying Wang9fe15ac2015-08-20 12:02:10 -0700328# Rule to install the module's companion init.rc.
329my_init_rc := $(LOCAL_INIT_RC_$(my_32_64_bit_suffix))
330my_init_rc_src :=
331my_init_rc_installed :=
332ifndef my_init_rc
333my_init_rc := $(LOCAL_INIT_RC)
334# Make sure we don't define the rule twice in multilib module.
335LOCAL_INIT_RC :=
336endif
337ifdef my_init_rc
338my_init_rc_src := $(LOCAL_PATH)/$(my_init_rc)
339my_init_rc_installed := $(TARGET_OUT$(partition_tag)_ETC)/init/$(notdir $(my_init_rc_src))
340$(my_init_rc_installed) : $(my_init_rc_src) | $(ACP)
341 @echo "Install: $@"
342 $(copy-file-to-new-target)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800343
Ying Wang9fe15ac2015-08-20 12:02:10 -0700344$(my_register_name) : $(my_init_rc_installed)
345endif # my_init_rc
346endif # !LOCAL_UNINSTALLABLE_MODULE
Joe Onoratoe334d252009-07-17 15:33:40 -0400347
348###########################################################
349## CHECK_BUILD goals
350###########################################################
Ying Wang6c1d1cc2014-09-29 14:34:32 -0700351my_checked_module :=
Joe Onoratoe334d252009-07-17 15:33:40 -0400352# If nobody has defined a more specific module for the
Ying Wang5a8d3452013-01-30 14:43:05 -0800353# checked modules, use LOCAL_BUILT_MODULE.
Ying Wang6c1d1cc2014-09-29 14:34:32 -0700354ifdef LOCAL_CHECKED_MODULE
355 my_checked_module := $(LOCAL_CHECKED_MODULE)
356else
357 my_checked_module := $(LOCAL_BUILT_MODULE)
Joe Onoratoe334d252009-07-17 15:33:40 -0400358endif
359
360# If they request that this module not be checked, then don't.
361# PLEASE DON'T SET THIS. ANY PLACES THAT SET THIS WITHOUT
362# GOOD REASON WILL HAVE IT REMOVED.
363ifdef LOCAL_DONT_CHECK_MODULE
Ying Wang6c1d1cc2014-09-29 14:34:32 -0700364 my_checked_module :=
Joe Onoratoe334d252009-07-17 15:33:40 -0400365endif
Ying Wang966c1e02014-05-20 14:43:51 -0700366# Don't check build target module defined for the 2nd arch
367ifndef LOCAL_IS_HOST_MODULE
Ying Wang6ef65192014-01-15 16:02:16 -0800368ifdef LOCAL_2ND_ARCH_VAR_PREFIX
Ying Wang6c1d1cc2014-09-29 14:34:32 -0700369 my_checked_module :=
Ying Wang6ef65192014-01-15 16:02:16 -0800370endif
Ying Wang966c1e02014-05-20 14:43:51 -0700371endif
Joe Onoratoe334d252009-07-17 15:33:40 -0400372
The Android Open Source Project88b60792009-03-03 19:28:42 -0800373###########################################################
Ying Wang16243612015-06-03 12:43:50 -0700374## Compatibiliy suite files.
375###########################################################
376ifdef LOCAL_COMPATIBILITY_SUITE
377ifneq ($(words $(LOCAL_COMPATIBILITY_SUITE)),1)
378$(error $(LOCAL_PATH):$(LOCAL_MODULE) LOCAL_COMPATIBILITY_SUITE can be only one name)
379endif
380
Ying Wang719f1982015-10-20 18:18:40 -0700381# The module itself.
382my_compat_dist := \
383 $(LOCAL_BUILT_MODULE):$(COMPATIBILITY_TESTCASES_OUT_$(LOCAL_COMPATIBILITY_SUITE))/$(my_installed_module_stem)
384
385# Make sure we only add the files once for multilib modules.
386ifndef $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files
387$(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files := true
388
Ying Wang25e01172015-09-17 12:24:56 -0700389# LOCAL_COMPATIBILITY_SUPPORT_FILES is a list of <src>[:<dest>].
Ying Wang719f1982015-10-20 18:18:40 -0700390my_compat_dist += $(foreach f, $(LOCAL_COMPATIBILITY_SUPPORT_FILES),\
Ying Wang25e01172015-09-17 12:24:56 -0700391 $(eval p := $(subst :,$(space),$(f)))\
Ying Wang150fd172016-02-16 15:42:26 -0800392 $(eval s := $(word 1,$(p)))\
393 $(eval d := $(COMPATIBILITY_TESTCASES_OUT_$(LOCAL_COMPATIBILITY_SUITE))/$(or $(word 2,$(p)),$(notdir $(word 1,$(p)))))\
Ying Wang25e01172015-09-17 12:24:56 -0700394 $(s):$(d))
Ying Wang16243612015-06-03 12:43:50 -0700395
Ying Wang25e01172015-09-17 12:24:56 -0700396ifneq (,$(wildcard $(LOCAL_PATH)/AndroidTest.xml))
397my_compat_dist += \
398 $(LOCAL_PATH)/AndroidTest.xml:$(COMPATIBILITY_TESTCASES_OUT_$(LOCAL_COMPATIBILITY_SUITE))/$(LOCAL_MODULE).config
Ying Wang562d7002015-06-04 11:21:49 -0700399endif
Ying Wang16243612015-06-03 12:43:50 -0700400
Ying Wang25e01172015-09-17 12:24:56 -0700401ifneq (,$(wildcard $(LOCAL_PATH)/DynamicConfig.xml))
402my_compat_dist += \
403 $(LOCAL_PATH)/DynamicConfig.xml:$(COMPATIBILITY_TESTCASES_OUT_$(LOCAL_COMPATIBILITY_SUITE))/$(LOCAL_MODULE).dynamic
Stuart Scott8fe4bc72015-08-18 14:31:08 -0700404endif
Ying Wang719f1982015-10-20 18:18:40 -0700405endif # $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files
Stuart Scott8fe4bc72015-08-18 14:31:08 -0700406
Ying Wang25e01172015-09-17 12:24:56 -0700407my_compat_files := $(call copy-many-files, $(my_compat_dist))
408
Ying Wang16243612015-06-03 12:43:50 -0700409COMPATIBILITY.$(LOCAL_COMPATIBILITY_SUITE).FILES := \
410 $(COMPATIBILITY.$(LOCAL_COMPATIBILITY_SUITE).FILES) \
Ying Wang25e01172015-09-17 12:24:56 -0700411 $(my_compat_files)
Ying Wang16243612015-06-03 12:43:50 -0700412
413# Copy over the compatibility files when user runs mm/mmm.
Ying Wang25e01172015-09-17 12:24:56 -0700414$(my_register_name) : $(my_compat_files)
Ying Wang16243612015-06-03 12:43:50 -0700415endif # LOCAL_COMPATIBILITY_SUITE
416
417###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800418## Register with ALL_MODULES
419###########################################################
420
Ying Wang6ef65192014-01-15 16:02:16 -0800421ALL_MODULES += $(my_register_name)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800422
423# Don't use += on subvars, or else they'll end up being
424# recursively expanded.
Ying Wang6ef65192014-01-15 16:02:16 -0800425ALL_MODULES.$(my_register_name).CLASS := \
426 $(ALL_MODULES.$(my_register_name).CLASS) $(LOCAL_MODULE_CLASS)
427ALL_MODULES.$(my_register_name).PATH := \
428 $(ALL_MODULES.$(my_register_name).PATH) $(LOCAL_PATH)
429ALL_MODULES.$(my_register_name).TAGS := \
Ying Wang37bd1f22014-01-27 15:19:09 -0800430 $(ALL_MODULES.$(my_register_name).TAGS) $(my_module_tags)
Ying Wang6ef65192014-01-15 16:02:16 -0800431ALL_MODULES.$(my_register_name).CHECKED := \
Ying Wang6c1d1cc2014-09-29 14:34:32 -0700432 $(ALL_MODULES.$(my_register_name).CHECKED) $(my_checked_module)
Ying Wang6ef65192014-01-15 16:02:16 -0800433ALL_MODULES.$(my_register_name).BUILT := \
434 $(ALL_MODULES.$(my_register_name).BUILT) $(LOCAL_BUILT_MODULE)
Ying Wang3380d3a2014-05-19 13:03:36 -0700435ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
Ying Wang6ef65192014-01-15 16:02:16 -0800436ALL_MODULES.$(my_register_name).INSTALLED := \
Ying Wang9fe15ac2015-08-20 12:02:10 -0700437 $(strip $(ALL_MODULES.$(my_register_name).INSTALLED) \
438 $(LOCAL_INSTALLED_MODULE) $(my_init_rc_installed))
Ying Wang3380d3a2014-05-19 13:03:36 -0700439ALL_MODULES.$(my_register_name).BUILT_INSTALLED := \
Ying Wang9fe15ac2015-08-20 12:02:10 -0700440 $(strip $(ALL_MODULES.$(my_register_name).BUILT_INSTALLED) \
441 $(LOCAL_BUILT_MODULE):$(LOCAL_INSTALLED_MODULE) \
442 $(addprefix $(my_init_rc_src):,$(my_init_rc_installed)))
Ying Wang3380d3a2014-05-19 13:03:36 -0700443endif
Ying Wang3b81aab2014-05-05 16:46:52 -0700444ifdef LOCAL_PICKUP_FILES
445# Files or directories ready to pick up by the build system
446# when $(LOCAL_BUILT_MODULE) is done.
447ALL_MODULES.$(my_register_name).PICKUP_FILES := \
448 $(ALL_MODULES.$(my_register_name).PICKUP_FILES) $(LOCAL_PICKUP_FILES)
449endif
Dan Willemsen7a549852015-08-13 17:51:40 -0700450my_required_modules := $(LOCAL_REQUIRED_MODULES) \
451 $(LOCAL_REQUIRED_MODULES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
452ifdef LOCAL_IS_HOST_MODULE
453my_required_modules += $(LOCAL_REQUIRED_MODULES_$($(my_prefix)OS))
454endif
Ying Wang6ef65192014-01-15 16:02:16 -0800455ALL_MODULES.$(my_register_name).REQUIRED := \
Dan Willemsen7a549852015-08-13 17:51:40 -0700456 $(strip $(ALL_MODULES.$(my_register_name).REQUIRED) $(my_required_modules))
Yasuhiro Matsudaff82e822015-09-04 16:23:49 +0900457ALL_MODULES.$(my_register_name).EVENT_LOG_TAGS := \
458 $(ALL_MODULES.$(my_register_name).EVENT_LOG_TAGS) $(event_log_tags)
Ying Wang6ef65192014-01-15 16:02:16 -0800459ALL_MODULES.$(my_register_name).MAKEFILE := \
460 $(ALL_MODULES.$(my_register_name).MAKEFILE) $(LOCAL_MODULE_MAKEFILE)
Ying Wangdbb31be2011-12-09 15:11:57 -0800461ifdef LOCAL_MODULE_OWNER
Ying Wang6ef65192014-01-15 16:02:16 -0800462ALL_MODULES.$(my_register_name).OWNER := \
463 $(sort $(ALL_MODULES.$(my_register_name).OWNER) $(LOCAL_MODULE_OWNER))
Ying Wangdbb31be2011-12-09 15:11:57 -0800464endif
Ying Wang14a6cbd2014-02-10 22:26:23 -0800465ifdef LOCAL_2ND_ARCH_VAR_PREFIX
466ALL_MODULES.$(my_register_name).FOR_2ND_ARCH := true
467endif
Dan Willemsen057aaea2015-08-14 12:59:50 -0700468ALL_MODULES.$(my_register_name).FOR_HOST_CROSS := $(my_host_cross)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800469
Ying Wang6ef65192014-01-15 16:02:16 -0800470INSTALLABLE_FILES.$(LOCAL_INSTALLED_MODULE).MODULE := $(my_register_name)
Joe Onorato8a06bac2010-05-21 14:29:29 -0700471
Ying Wang39b9b692015-05-07 12:08:53 -0700472##########################################################
473# Track module-level dependencies.
474# Use $(LOCAL_MODULE) instead of $(my_register_name) to ignore module's bitness.
475ALL_DEPS.MODULES := $(sort $(ALL_DEPS.MODULES) $(LOCAL_MODULE))
476ALL_DEPS.$(LOCAL_MODULE).ALL_DEPS := $(sort \
477 $(ALL_MODULES.$(LOCAL_MODULE).ALL_DEPS) \
478 $(LOCAL_STATIC_LIBRARIES) \
479 $(LOCAL_WHOLE_STATIC_LIBRARIES) \
480 $(LOCAL_SHARED_LIBRARIES) \
481 $(LOCAL_STATIC_JAVA_LIBRARIES) \
482 $(LOCAL_JAVA_LIBRARIES)\
483 $(LOCAL_JNI_SHARED_LIBRARIES))
484
485ALL_DEPS.$(LOCAL_MODULE).LICENSE := $(sort $(ALL_DEPS.$(LOCAL_MODULE).LICENSE) $(license_files))
486
The Android Open Source Project88b60792009-03-03 19:28:42 -0800487###########################################################
Ying Wang37bd1f22014-01-27 15:19:09 -0800488## Take care of my_module_tags
The Android Open Source Project88b60792009-03-03 19:28:42 -0800489###########################################################
490
491# Keep track of all the tags we've seen.
Ying Wang37bd1f22014-01-27 15:19:09 -0800492ALL_MODULE_TAGS := $(sort $(ALL_MODULE_TAGS) $(my_module_tags))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800493
The Android Open Source Project88b60792009-03-03 19:28:42 -0800494# Add this module name to the tag list of each specified tag.
Ying Wang37bd1f22014-01-27 15:19:09 -0800495$(foreach tag,$(my_module_tags),\
Ying Wang6ef65192014-01-15 16:02:16 -0800496 $(eval ALL_MODULE_NAME_TAGS.$(tag) += $(my_register_name)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800497
The Android Open Source Project88b60792009-03-03 19:28:42 -0800498###########################################################
Ying Wangef4d82f2013-01-29 16:59:18 -0800499## umbrella targets used to verify builds
500###########################################################
Ying Wangef4d82f2013-01-29 16:59:18 -0800501j_or_n :=
502ifneq (,$(filter EXECUTABLES SHARED_LIBRARIES STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS)))
503j_or_n := native
504else
505ifneq (,$(filter JAVA_LIBRARIES APPS,$(LOCAL_MODULE_CLASS)))
506j_or_n := java
Ying Wangef4d82f2013-01-29 16:59:18 -0800507endif
508endif
509ifdef LOCAL_IS_HOST_MODULE
510h_or_t := host
511else
512h_or_t := target
513endif
514
515ifdef j_or_n
Ying Wang6c1d1cc2014-09-29 14:34:32 -0700516$(j_or_n) $(h_or_t) $(j_or_n)-$(h_or_t) : $(my_checked_module)
Ying Wang37bd1f22014-01-27 15:19:09 -0800517ifneq (,$(filter $(my_module_tags),tests))
Ying Wang6c1d1cc2014-09-29 14:34:32 -0700518$(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 -0800519endif
520endif
521
522###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800523## NOTICE files
524###########################################################
525
Ying Wang13d69502012-11-01 17:22:33 -0700526include $(BUILD_NOTICE_FILE)