blob: 96d7f3983a905bfecf48fca04929db332b5cf378 [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
Ying Wang13d69502012-11-01 17:22:33 -070037 my_prefix := HOST_
38 my_host := host-
The Android Open Source Project88b60792009-03-03 19:28:42 -080039else
Ying Wang13d69502012-11-01 17:22:33 -070040 my_prefix := TARGET_
41 my_host :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080042endif
43
44###########################################################
45## Validate and define fallbacks for input LOCAL_* variables.
46###########################################################
47
48## Dump a .csv file of all modules and their tags
49#ifneq ($(tag-list-first-time),false)
50#$(shell rm -f tag-list.csv)
51#tag-list-first-time := false
52#endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080053#$(shell echo $(lastword $(filter-out config/% out/%,$(MAKEFILE_LIST))),$(LOCAL_MODULE),$(strip $(LOCAL_MODULE_CLASS)),$(subst $(space),$(comma),$(sort $(LOCAL_MODULE_TAGS))) >> tag-list.csv)
54
Ying Wang6e371e42012-05-15 14:31:26 -070055LOCAL_UNINSTALLABLE_MODULE := $(strip $(LOCAL_UNINSTALLABLE_MODULE))
The Android Open Source Project88b60792009-03-03 19:28:42 -080056LOCAL_MODULE_TAGS := $(sort $(LOCAL_MODULE_TAGS))
57ifeq (,$(LOCAL_MODULE_TAGS))
Joe Onorato6a185e42012-05-22 14:08:50 -070058 LOCAL_MODULE_TAGS := optional
Ying Wang2fd81cf2010-12-10 11:17:28 -080059endif
Joe Onorato918ee312012-05-18 20:43:14 -070060
Joe Onorato6a185e42012-05-22 14:08:50 -070061# User tags are not allowed anymore. Fail early because it will not be installed
62# like it used to be.
63ifneq ($(filter $(LOCAL_MODULE_TAGS),user),)
64 $(warning *** Module name: $(LOCAL_MODULE))
65 $(warning *** Makefile location: $(LOCAL_MODULE_MAKEFILE))
66 $(warning * )
67 $(warning * Module is attempting to use the 'user' tag. This)
68 $(warning * used to cause the module to be installed automatically.)
69 $(warning * Now, the module must be listed in the PRODUCT_PACKAGES)
70 $(warning * section of a product makefile to have it installed.)
71 $(warning * )
72 $(error user tag detected on module.)
73endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080074
Jean-Baptiste Querua831cbd2010-01-07 11:06:50 -080075# Only the tags mentioned in this test are expected to be set by module
76# makefiles. Anything else is either a typo or a source of unexpected
77# behaviors.
Elliott Hughes17753f52013-11-05 09:05:50 -080078ifneq ($(filter-out debug eng tests optional samples shell_mksh,$(LOCAL_MODULE_TAGS)),)
Jean-Baptiste Querua831cbd2010-01-07 11:06:50 -080079$(warning unusual tags $(LOCAL_MODULE_TAGS) on $(LOCAL_MODULE) at $(LOCAL_PATH))
80endif
81
The Android Open Source Project88b60792009-03-03 19:28:42 -080082# Add implicit tags.
83#
84# If the local directory or one of its parents contains a MODULE_LICENSE_GPL
Ying Wanga67ce692011-03-03 13:29:38 -080085# file, tag the module as "gnu". Search for "*_GPL*" and "*_MPL*" so that we can also
The Android Open Source Project88b60792009-03-03 19:28:42 -080086# find files like MODULE_LICENSE_GPL_AND_AFL but exclude files like
87# MODULE_LICENSE_LGPL.
88#
Ying Wangfd626f22011-12-12 12:57:38 -080089gpl_license_file := $(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*_GPL* MODULE_LICENSE*_MPL*)
90ifneq ($(gpl_license_file),)
The Android Open Source Project88b60792009-03-03 19:28:42 -080091 LOCAL_MODULE_TAGS += gnu
Ying Wangfd626f22011-12-12 12:57:38 -080092 ALL_GPL_MODULE_LICENSE_FILES := $(sort $(ALL_GPL_MODULE_LICENSE_FILES) $(gpl_license_file))
The Android Open Source Project88b60792009-03-03 19:28:42 -080093endif
94
The Android Open Source Project88b60792009-03-03 19:28:42 -080095LOCAL_MODULE_CLASS := $(strip $(LOCAL_MODULE_CLASS))
96ifneq ($(words $(LOCAL_MODULE_CLASS)),1)
97 $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS must contain exactly one word, not "$(LOCAL_MODULE_CLASS)")
98endif
99
Ying Wang6e371e42012-05-15 14:31:26 -0700100ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800101LOCAL_MODULE_PATH := $(strip $(LOCAL_MODULE_PATH))
102ifeq ($(LOCAL_MODULE_PATH),)
Ying Wang5338fbf2013-05-08 15:49:08 -0700103 ifdef LOCAL_IS_HOST_MODULE
104 partition_tag :=
105 else
106 ifeq (true,$(LOCAL_PROPRIETARY_MODULE))
107 partition_tag := _VENDOR
108 else
109 # The definition of should-install-to-system will be different depending
110 # on which goal (e.g., sdk or just droid) is being built.
111 partition_tag := $(if $(call should-install-to-system,$(LOCAL_MODULE_TAGS)),,_DATA)
112 endif
113 endif
114 install_path_var := $(my_prefix)OUT$(partition_tag)_$(LOCAL_MODULE_CLASS)
115 ifeq (true,$(LOCAL_PRIVILEGED_MODULE))
116 install_path_var := $(install_path_var)_PRIVILEGED
117 endif
118
119 LOCAL_MODULE_PATH := $($(install_path_var))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800120 ifeq ($(strip $(LOCAL_MODULE_PATH)),)
Ying Wang5338fbf2013-05-08 15:49:08 -0700121 $(error $(LOCAL_PATH): unhandled install path "$(install_path_var)")
The Android Open Source Project88b60792009-03-03 19:28:42 -0800122 endif
123endif
Ying Wang6e371e42012-05-15 14:31:26 -0700124endif # not LOCAL_UNINSTALLABLE_MODULE
The Android Open Source Project88b60792009-03-03 19:28:42 -0800125
126ifneq ($(strip $(LOCAL_BUILT_MODULE)$(LOCAL_INSTALLED_MODULE)),)
127 $(error $(LOCAL_PATH): LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE must not be defined by component makefiles)
128endif
129
130# Make sure that this IS_HOST/CLASS/MODULE combination is unique.
131module_id := MODULE.$(if \
132 $(LOCAL_IS_HOST_MODULE),HOST,TARGET).$(LOCAL_MODULE_CLASS).$(LOCAL_MODULE)
133ifdef $(module_id)
134$(error $(LOCAL_PATH): $(module_id) already defined by $($(module_id)))
135endif
136$(module_id) := $(LOCAL_PATH)
137
138intermediates := $(call local-intermediates-dir)
139intermediates.COMMON := $(call local-intermediates-dir,COMMON)
140
141###########################################################
142# Pick a name for the intermediate and final targets
143###########################################################
Ying Wang24084792013-09-24 15:56:11 -0700144ifndef LOCAL_MODULE_STEM
The Android Open Source Project88b60792009-03-03 19:28:42 -0800145 LOCAL_MODULE_STEM := $(LOCAL_MODULE)
146endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800147
Ying Wang24084792013-09-24 15:56:11 -0700148ifndef LOCAL_BUILT_MODULE_STEM
149 LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE_STEM)$(LOCAL_MODULE_SUFFIX)
150endif
151
152ifndef LOCAL_INSTALLED_MODULE_STEM
153 LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE_STEM)$(LOCAL_MODULE_SUFFIX)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800154endif
155
156# OVERRIDE_BUILT_MODULE_PATH is only allowed to be used by the
157# internal SHARED_LIBRARIES build files.
158OVERRIDE_BUILT_MODULE_PATH := $(strip $(OVERRIDE_BUILT_MODULE_PATH))
159ifdef OVERRIDE_BUILT_MODULE_PATH
160 ifneq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
161 $(error $(LOCAL_PATH): Illegal use of OVERRIDE_BUILT_MODULE_PATH)
162 endif
163 built_module_path := $(OVERRIDE_BUILT_MODULE_PATH)
164else
165 built_module_path := $(intermediates)
166endif
167LOCAL_BUILT_MODULE := $(built_module_path)/$(LOCAL_BUILT_MODULE_STEM)
168built_module_path :=
169
Ying Wang162991b2011-09-07 10:21:42 -0700170ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
Jeff Brown703e7c62011-02-04 20:15:00 -0800171 LOCAL_INSTALLED_MODULE := $(LOCAL_MODULE_PATH)/$(LOCAL_INSTALLED_MODULE_STEM)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800172endif
173
174# Assemble the list of targets to create PRIVATE_ variables for.
175LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE)
176
177
178###########################################################
179## AIDL: Compile .aidl files to .java
180###########################################################
181
182aidl_sources := $(filter %.aidl,$(LOCAL_SRC_FILES))
183
184ifneq ($(strip $(aidl_sources)),)
185
186aidl_java_sources := $(patsubst %.aidl,%.java,$(addprefix $(intermediates.COMMON)/src/, $(aidl_sources)))
187aidl_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(aidl_sources))
188
Ying Wange3265fb2010-01-25 09:56:41 -0800189aidl_preprocess_import :=
190LOCAL_SDK_VERSION:=$(strip $(LOCAL_SDK_VERSION))
191ifdef LOCAL_SDK_VERSION
Ying Wang0ec188f2012-05-10 17:25:51 -0700192ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current)
193 # LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS
Ying Wanga07d37b2010-06-09 11:43:33 -0700194 aidl_preprocess_import := $(TARGET_OUT_COMMON_INTERMEDIATES)/framework.aidl
195else
196 aidl_preprocess_import := $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_VERSION)/framework.aidl
Ying Wange3265fb2010-01-25 09:56:41 -0800197endif # !current
Ying Wangd74b5382013-10-01 18:16:45 -0700198else
199# build against the platform.
200LOCAL_AIDL_INCLUDES += $(FRAMEWORKS_BASE_JAVA_SRC_DIRS)
Ying Wange3265fb2010-01-25 09:56:41 -0800201endif # LOCAL_SDK_VERSION
Ying Wanga07d37b2010-06-09 11:43:33 -0700202$(aidl_java_sources): PRIVATE_AIDL_FLAGS := -b $(addprefix -p,$(aidl_preprocess_import)) -I$(LOCAL_PATH) -I$(LOCAL_PATH)/src $(addprefix -I,$(LOCAL_AIDL_INCLUDES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800203
Ying Wanga7d9ca32011-07-13 14:29:33 -0700204$(aidl_java_sources): $(intermediates.COMMON)/src/%.java: $(TOPDIR)$(LOCAL_PATH)/%.aidl $(LOCAL_ADDITIONAL_DEPENDENCIES) $(AIDL) $(aidl_preprocess_import)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800205 $(transform-aidl-to-java)
206-include $(aidl_java_sources:%.java=%.P)
207
208else
209aidl_java_sources :=
210endif
211
212###########################################################
Doug Zongker9bd49622009-11-30 14:28:59 -0800213## logtags: Add .logtags files to global list, emit java source
214###########################################################
215
216logtags_sources := $(filter %.logtags,$(LOCAL_SRC_FILES))
217
218ifneq ($(strip $(logtags_sources)),)
219
220event_log_tags := $(addprefix $(LOCAL_PATH)/,$(logtags_sources))
221
222# Emit a java source file with constants for the tags, if
223# LOCAL_MODULE_CLASS is "APPS" or "JAVA_LIBRARIES".
224ifneq ($(strip $(filter $(LOCAL_MODULE_CLASS),APPS JAVA_LIBRARIES)),)
225
226logtags_java_sources := $(patsubst %.logtags,%.java,$(addprefix $(intermediates.COMMON)/src/, $(logtags_sources)))
227logtags_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(logtags_sources))
228
Joe Onoratob7510532010-07-14 10:22:54 -0700229$(logtags_java_sources): $(intermediates.COMMON)/src/%.java: $(TOPDIR)$(LOCAL_PATH)/%.logtags $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
Doug Zongker9bd49622009-11-30 14:28:59 -0800230 $(transform-logtags-to-java)
231
232endif
233
234else
235logtags_java_sources :=
236event_log_tags :=
237endif
238
239###########################################################
Ying Wanga5fc87a2010-11-02 18:43:16 -0700240## .proto files: Compile proto files to .java
241###########################################################
242proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES))
243# Because names of the .java files compiled from .proto files are unknown until the
244# .proto files are compiled, we use a timestamp file as depedency.
245proto_java_sources_file_stamp :=
246ifneq ($(proto_sources),)
247proto_sources_fullpath := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(proto_sources))
248# By putting the generated java files into $(LOCAL_INTERMEDIATE_SOURCE_DIR), they will be
249# automatically found by the java compiling function transform-java-to-classes.jar.
Ying Wang60293912010-11-05 11:20:03 -0700250ifneq ($(LOCAL_INTERMEDIATE_SOURCE_DIR),)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700251proto_java_intemediate_dir := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/proto
Ying Wang60293912010-11-05 11:20:03 -0700252else
253# LOCAL_INTERMEDIATE_SOURCE_DIR may be not defined in non-java modules.
254proto_java_intemediate_dir := $(intermediates)/proto
255endif
Ying Wanga5fc87a2010-11-02 18:43:16 -0700256proto_java_sources_file_stamp := $(proto_java_intemediate_dir)/Proto.stamp
257proto_java_sources_dir := $(proto_java_intemediate_dir)/src
258
259$(proto_java_sources_file_stamp): PRIVATE_PROTO_INCLUDES := $(TOP)
260$(proto_java_sources_file_stamp): PRIVATE_PROTO_SRC_FILES := $(proto_sources_fullpath)
261$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_DIR := $(proto_java_sources_dir)
262ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro)
263$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javamicro_out
264else
Ulas Kirazci76e3a392013-03-28 14:02:14 -0700265 ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nano)
266$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javanano_out
267 else
Ying Wanga5fc87a2010-11-02 18:43:16 -0700268$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --java_out
Ulas Kirazci76e3a392013-03-28 14:02:14 -0700269 endif
Ying Wanga5fc87a2010-11-02 18:43:16 -0700270endif
Ying Wang33c0d952010-11-05 11:30:58 -0700271$(proto_java_sources_file_stamp): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS)
Ulas Kirazci6e485b52013-07-25 12:28:19 -0700272$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_PARAMS := $(LOCAL_PROTO_JAVA_OUTPUT_PARAMS)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700273$(proto_java_sources_file_stamp) : $(proto_sources_fullpath) $(PROTOC)
274 $(call transform-proto-to-java)
275
276#TODO: protoc should output the dependencies introduced by imports.
277
278LOCAL_INTERMEDIATE_TARGETS += $(proto_java_sources_file_stamp)
279endif # proto_sources
280
281
282###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800283## Java: Compile .java files to .class
284###########################################################
285#TODO: pull this into java.make once host and target are combined
286
Ying Wang52911302010-05-26 13:13:56 -0700287java_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) $(aidl_java_sources) $(logtags_java_sources) \
288 $(filter %.java,$(LOCAL_GENERATED_SOURCES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800289all_java_sources := $(java_sources) $(addprefix $($(my_prefix)OUT_COMMON_INTERMEDIATES)/, $(filter %.java,$(LOCAL_INTERMEDIATE_SOURCES)))
290
291## Java resources #########################################
292
293# Look for resource files in any specified directories.
294# Non-java and non-doc files will be picked up as resources
295# and included in the output jar file.
296java_resource_file_groups :=
297
298LOCAL_JAVA_RESOURCE_DIRS := $(strip $(LOCAL_JAVA_RESOURCE_DIRS))
299ifneq ($(LOCAL_JAVA_RESOURCE_DIRS),)
300 # This makes a list of words like
301 # <dir1>::<file1>:<file2> <dir2>::<file1> <dir3>:
302 # where each of the files is relative to the directory it's grouped with.
303 # Directories that don't contain any resource files will result in groups
304 # that end with a colon, and they are stripped out in the next step.
305 java_resource_file_groups += \
306 $(foreach dir,$(LOCAL_JAVA_RESOURCE_DIRS), \
307 $(subst $(space),:,$(strip \
308 $(TOP_DIR)$(LOCAL_PATH)/$(dir): \
309 $(patsubst ./%,%,$(shell cd $(TOP_DIR)$(LOCAL_PATH)/$(dir) && \
310 find . \
311 -type d -a -name ".svn" -prune -o \
312 -type f \
313 -a \! -name "*.java" \
314 -a \! -name "package.html" \
315 -a \! -name "overview.html" \
316 -a \! -name ".*.swp" \
317 -a \! -name ".DS_Store" \
318 -a \! -name "*~" \
319 -print \
320 )) \
321 )) \
322 )
323 java_resource_file_groups := $(filter-out %:,$(java_resource_file_groups))
324endif # LOCAL_JAVA_RESOURCE_DIRS
325
326LOCAL_JAVA_RESOURCE_FILES := $(strip $(LOCAL_JAVA_RESOURCE_FILES))
327ifneq ($(LOCAL_JAVA_RESOURCE_FILES),)
328 java_resource_file_groups += \
329 $(foreach f,$(LOCAL_JAVA_RESOURCE_FILES), \
330 $(patsubst %/,%,$(dir $(f)))::$(notdir $(f)) \
331 )
332endif # LOCAL_JAVA_RESOURCE_FILES
333
334ifdef java_resource_file_groups
335 # The full paths to all resources, used for dependencies.
336 java_resource_sources := \
337 $(foreach group,$(java_resource_file_groups), \
338 $(addprefix $(word 1,$(subst :,$(space),$(group)))/, \
339 $(wordlist 2,9999,$(subst :,$(space),$(group))) \
340 ) \
341 )
342 # The arguments to jar that will include these files in a jar file.
Ying Wang194a8ec2011-06-06 14:34:52 -0700343 # Quote the file name to handle special characters (such as #) correctly.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800344 extra_jar_args := \
345 $(foreach group,$(java_resource_file_groups), \
Ying Wang194a8ec2011-06-06 14:34:52 -0700346 $(addprefix -C "$(word 1,$(subst :,$(space),$(group)))" , \
347 $(foreach w, $(wordlist 2,9999,$(subst :,$(space),$(group))), "$(w)" ) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800348 ) \
349 )
350 java_resource_file_groups :=
351else
352 java_resource_sources :=
353 extra_jar_args :=
354endif # java_resource_file_groups
355
356## PRIVATE java vars ######################################
Ying Wang990cf5e2013-08-28 13:04:46 -0700357# LOCAL_SOURCE_FILES_ALL_GENERATED is set only if the module does not have static source files,
358# but generated source files in its LOCAL_INTERMEDIATE_SOURCE_DIR.
359# You have to set up the dependency in some other way.
360need_compile_java := $(strip $(all_java_sources)$(all_res_assets))$(LOCAL_STATIC_JAVA_LIBRARIES)$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED))
361ifdef need_compile_java
The Android Open Source Project88b60792009-03-03 19:28:42 -0800362
363full_static_java_libs := \
364 $(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES), \
365 $(call intermediates-dir-for, \
Ying Wanga83940f2010-09-24 18:09:04 -0700366 JAVA_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),COMMON)/javalib.jar)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800367
368$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_INSTALL_DIR := $(dir $(LOCAL_INSTALLED_MODULE))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800369$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates)/classes
370$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates)/src
371$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAVA_SOURCES := $(all_java_sources)
372$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAVA_OBJECTS := $(patsubst %.java,%.class,$(LOCAL_SRC_FILES))
373ifeq ($(my_prefix),TARGET_)
Joe Onoratoe62902c2009-09-23 15:28:12 -0700374ifeq ($(LOCAL_SDK_VERSION),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800375$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,core)
Ying Wanga07d37b2010-06-09 11:43:33 -0700376else
Ying Wang0ec188f2012-05-10 17:25:51 -0700377ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current)
378# LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS.
Ying Wanga07d37b2010-06-09 11:43:33 -0700379$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,android_stubs_current)
380else
381$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,sdk_v$(LOCAL_SDK_VERSION))
382endif # current
383endif # LOCAL_SDK_VERSION
384endif # TARGET_
The Android Open Source Project88b60792009-03-03 19:28:42 -0800385$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR)
386$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args)
387$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASSET_DIR := $(LOCAL_ASSET_DIR)
388$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_STATIC_JAVA_LIBRARIES := $(full_static_java_libs)
389
390# full_java_libs: The list of files that should be used as the classpath.
391# Using this list as a dependency list WILL NOT WORK.
392# full_java_lib_deps: Should be specified as a prerequisite of this module
393# to guarantee that the files in full_java_libs will
394# be up-to-date.
395ifdef LOCAL_IS_HOST_MODULE
Ying Wang73ca57f2010-09-10 18:38:10 -0700396ifeq ($(LOCAL_BUILD_HOST_DEX),true)
Ying Wang015edd22011-01-20 15:01:56 -0800397$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,core-hostdex,$(LOCAL_IS_HOST_MODULE))
398
Ying Wang7311a342013-08-21 18:32:49 -0700399full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
Ying Wang73ca57f2010-09-10 18:38:10 -0700400full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
401else
Ying Wang015edd22011-01-20 15:01:56 -0800402$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH :=
403
Ying Wang7311a342013-08-21 18:32:49 -0700404full_shared_java_libs := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/,\
405 $(addsuffix $(COMMON_JAVA_PACKAGE_SUFFIX),$(LOCAL_JAVA_LIBRARIES)))
406full_java_lib_deps := $(full_shared_java_libs)
Ying Wang73ca57f2010-09-10 18:38:10 -0700407endif # LOCAL_BUILD_HOST_DEX
The Android Open Source Project88b60792009-03-03 19:28:42 -0800408else
Ying Wang7311a342013-08-21 18:32:49 -0700409full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800410full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
Ying Wange3265fb2010-01-25 09:56:41 -0800411endif # !LOCAL_IS_HOST_MODULE
Ying Wang7311a342013-08-21 18:32:49 -0700412full_java_libs := $(full_shared_java_libs) $(full_static_java_libs) $(LOCAL_CLASSPATH)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800413full_java_lib_deps += $(full_static_java_libs) $(LOCAL_CLASSPATH)
414
Dianne Hackborna1fece02013-03-11 18:04:55 -0700415# This is set by packages that are linking to other packages that export
416# shared libraries, allowing them to make use of the code in the linked apk.
417LOCAL_APK_LIBRARIES := $(strip $(LOCAL_APK_LIBRARIES))
418ifdef LOCAL_APK_LIBRARIES
419 link_apk_libraries := \
420 $(foreach lib,$(LOCAL_APK_LIBRARIES), \
421 $(call intermediates-dir-for, \
422 APPS,$(lib),,COMMON)/classes.jar)
423
424 # link against the jar with full original names (before proguard processing).
Ying Wang638ce572013-08-23 11:59:49 -0700425 full_shared_java_libs += $(link_apk_libraries)
Dianne Hackborna1fece02013-03-11 18:04:55 -0700426 full_java_libs += $(link_apk_libraries)
427 full_java_lib_deps += $(link_apk_libraries)
428endif
429
The Android Open Source Project88b60792009-03-03 19:28:42 -0800430# This is set by packages that contain instrumentation, allowing them to
431# link against the package they are instrumenting. Currently only one such
432# package is allowed.
433LOCAL_INSTRUMENTATION_FOR := $(strip $(LOCAL_INSTRUMENTATION_FOR))
434ifdef LOCAL_INSTRUMENTATION_FOR
435 ifneq ($(words $(LOCAL_INSTRUMENTATION_FOR)),1)
436 $(error \
437 $(LOCAL_PATH): Multiple LOCAL_INSTRUMENTATION_FOR members defined)
438 endif
439
The Android Open Source Project88b60792009-03-03 19:28:42 -0800440 link_instr_intermediates_dir.COMMON := $(call intermediates-dir-for, \
441 APPS,$(LOCAL_INSTRUMENTATION_FOR),,COMMON)
Ying Wang3b2bdf12010-02-01 09:51:23 -0800442 # link against the jar with full original names (before proguard processing).
Ying Wang7311a342013-08-21 18:32:49 -0700443 link_instr_classes_jar := $(link_instr_intermediates_dir.COMMON)/classes.jar
444 full_java_libs += $(link_instr_classes_jar)
445 full_java_lib_deps += $(link_instr_classes_jar)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800446endif
447
Ying Wangc06243d2010-04-26 20:09:56 -0700448jar_manifest_file :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800449ifneq ($(strip $(LOCAL_JAR_MANIFEST)),)
Ying Wangc06243d2010-04-26 20:09:56 -0700450jar_manifest_file := $(LOCAL_PATH)/$(LOCAL_JAR_MANIFEST)
451$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST := $(jar_manifest_file)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800452else
453$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST :=
454endif
455
Ying Wang990cf5e2013-08-28 13:04:46 -0700456endif # need_compile_java
The Android Open Source Project88b60792009-03-03 19:28:42 -0800457
458
459###########################################################
460## make clean- targets
461###########################################################
462cleantarget := clean-$(LOCAL_MODULE)
463$(cleantarget) : PRIVATE_MODULE := $(LOCAL_MODULE)
Ying Wang4d063412013-03-22 18:52:57 -0700464$(cleantarget) : PRIVATE_CLEAN_FILES := \
Ying Wang95221ca2012-11-07 14:07:34 -0800465 $(LOCAL_BUILT_MODULE) \
466 $(LOCAL_INSTALLED_MODULE) \
467 $(intermediates)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800468$(cleantarget)::
469 @echo "Clean: $(PRIVATE_MODULE)"
470 $(hide) rm -rf $(PRIVATE_CLEAN_FILES)
471
472###########################################################
473## Common definitions for module.
474###########################################################
475
Ying Wang95221ca2012-11-07 14:07:34 -0800476# aapt doesn't accept multiple --extra-packages flags.
477# We have to collapse them into a single --extra-packages flag here.
478LOCAL_AAPT_FLAGS := $(strip $(LOCAL_AAPT_FLAGS))
479ifdef LOCAL_AAPT_FLAGS
480ifeq ($(filter 0 1,$(words $(filter --extra-packages,$(LOCAL_AAPT_FLAGS)))),)
481aapt_flags := $(subst --extra-packages$(space),--extra-packages@,$(LOCAL_AAPT_FLAGS))
482aapt_flags_extra_packages := $(patsubst --extra-packages@%,%,$(filter --extra-packages@%,$(aapt_flags)))
483aapt_flags_extra_packages := $(sort $(subst :,$(space),$(aapt_flags_extra_packages)))
484LOCAL_AAPT_FLAGS := $(filter-out --extra-packages@%,$(aapt_flags)) \
485 --extra-packages $(subst $(space),:,$(aapt_flags_extra_packages))
486aapt_flags_extra_packages :=
487aapt_flags :=
488endif
489endif
490
The Android Open Source Project88b60792009-03-03 19:28:42 -0800491# Propagate local configuration options to this target.
492$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PATH:=$(LOCAL_PATH)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800493$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_AAPT_FLAGS:= $(LOCAL_AAPT_FLAGS)
494$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_JAVA_LIBRARIES:= $(LOCAL_JAVA_LIBRARIES)
Jeff Hamiltonbb67d212010-02-05 22:36:42 -0600495$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MANIFEST_PACKAGE_NAME:= $(LOCAL_MANIFEST_PACKAGE_NAME)
Ying Wang3dae0ee2010-09-02 15:41:01 -0700496$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MANIFEST_INSTRUMENTATION_FOR:= $(LOCAL_MANIFEST_INSTRUMENTATION_FOR)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800497
498$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_ALL_JAVA_LIBRARIES:= $(full_java_libs)
499$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_IS_HOST_MODULE := $(LOCAL_IS_HOST_MODULE)
500$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_HOST:= $(my_host)
501
Dima Zavin46e9bec2009-05-27 19:41:07 -0700502$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_INTERMEDIATES_DIR:= $(intermediates)
503
The Android Open Source Project88b60792009-03-03 19:28:42 -0800504# Tell the module and all of its sub-modules who it is.
505$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MODULE:= $(LOCAL_MODULE)
506
507# Provide a short-hand for building this module.
508# We name both BUILT and INSTALLED in case
509# LOCAL_UNINSTALLABLE_MODULE is set.
510.PHONY: $(LOCAL_MODULE)
511$(LOCAL_MODULE): $(LOCAL_BUILT_MODULE) $(LOCAL_INSTALLED_MODULE)
512
513###########################################################
514## Module installation rule
515###########################################################
516
517# Some hosts do not have ACP; override the LOCAL version if that's the case.
518ifneq ($(strip $(HOST_ACP_UNAVAILABLE)),)
519 LOCAL_ACP_UNAVAILABLE := $(strip $(HOST_ACP_UNAVAILABLE))
520endif
521
522ifndef LOCAL_UNINSTALLABLE_MODULE
523 # Define a copy rule to install the module.
524 # acp and libraries that it uses can't use acp for
525 # installation; hence, LOCAL_ACP_UNAVAILABLE.
Ying Wange56605a2013-02-06 11:44:41 -0800526$(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800527ifneq ($(LOCAL_ACP_UNAVAILABLE),true)
528$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE) | $(ACP)
529 @echo "Install: $@"
Ying Wang84ed6fa2011-01-18 17:21:20 -0800530 $(copy-file-to-new-target)
Ying Wange56605a2013-02-06 11:44:41 -0800531 $(PRIVATE_POST_INSTALL_CMD)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800532else
533$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE)
534 @echo "Install: $@"
535 $(copy-file-to-target-with-cp)
536endif
537
Ying Wang79e3dec2011-10-24 12:17:03 -0700538ifdef LOCAL_DEX_PREOPT
Ying Wange7874c42010-09-17 16:36:06 -0700539installed_odex := $(basename $(LOCAL_INSTALLED_MODULE)).odex
540built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex
Chih-Wei Huang868e0c52013-04-15 17:12:19 +0800541$(installed_odex) : $(built_odex) $(LOCAL_BUILT_MODULE) | $(ACP)
Ying Wange7874c42010-09-17 16:36:06 -0700542 @echo "Install: $@"
543 $(copy-file-to-target)
544
Ying Wang84ed6fa2011-01-18 17:21:20 -0800545$(LOCAL_INSTALLED_MODULE) : $(installed_odex)
Ying Wange7874c42010-09-17 16:36:06 -0700546endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800547endif # !LOCAL_UNINSTALLABLE_MODULE
548
Joe Onoratoe334d252009-07-17 15:33:40 -0400549
550###########################################################
551## CHECK_BUILD goals
552###########################################################
553
Ying Wang990cf5e2013-08-28 13:04:46 -0700554ifdef java_alternative_checked_module
555 LOCAL_CHECKED_MODULE := $(java_alternative_checked_module)
556endif
557
Joe Onoratoe334d252009-07-17 15:33:40 -0400558# If nobody has defined a more specific module for the
Ying Wang5a8d3452013-01-30 14:43:05 -0800559# checked modules, use LOCAL_BUILT_MODULE.
Joe Onoratoe334d252009-07-17 15:33:40 -0400560ifndef LOCAL_CHECKED_MODULE
Ying Wang5a8d3452013-01-30 14:43:05 -0800561 LOCAL_CHECKED_MODULE := $(LOCAL_BUILT_MODULE)
Joe Onoratoe334d252009-07-17 15:33:40 -0400562endif
563
564# If they request that this module not be checked, then don't.
565# PLEASE DON'T SET THIS. ANY PLACES THAT SET THIS WITHOUT
566# GOOD REASON WILL HAVE IT REMOVED.
567ifdef LOCAL_DONT_CHECK_MODULE
568 LOCAL_CHECKED_MODULE :=
569endif
570
The Android Open Source Project88b60792009-03-03 19:28:42 -0800571###########################################################
572## Register with ALL_MODULES
573###########################################################
574
575ALL_MODULES += $(LOCAL_MODULE)
576
577# Don't use += on subvars, or else they'll end up being
578# recursively expanded.
Joe Onorato8a06bac2010-05-21 14:29:29 -0700579ALL_MODULES.$(LOCAL_MODULE).CLASS := \
580 $(ALL_MODULES.$(LOCAL_MODULE).CLASS) $(LOCAL_MODULE_CLASS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800581ALL_MODULES.$(LOCAL_MODULE).PATH := \
582 $(ALL_MODULES.$(LOCAL_MODULE).PATH) $(LOCAL_PATH)
583ALL_MODULES.$(LOCAL_MODULE).TAGS := \
584 $(ALL_MODULES.$(LOCAL_MODULE).TAGS) $(LOCAL_MODULE_TAGS)
Joe Onoratoe334d252009-07-17 15:33:40 -0400585ALL_MODULES.$(LOCAL_MODULE).CHECKED := \
586 $(ALL_MODULES.$(LOCAL_MODULE).CHECKED) $(LOCAL_CHECKED_MODULE)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800587ALL_MODULES.$(LOCAL_MODULE).BUILT := \
588 $(ALL_MODULES.$(LOCAL_MODULE).BUILT) $(LOCAL_BUILT_MODULE)
589ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
Ying Wangfb03fb32012-10-03 15:22:51 -0700590 $(strip $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(LOCAL_INSTALLED_MODULE))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800591ALL_MODULES.$(LOCAL_MODULE).REQUIRED := \
592 $(ALL_MODULES.$(LOCAL_MODULE).REQUIRED) $(LOCAL_REQUIRED_MODULES)
Doug Zongker9bd49622009-11-30 14:28:59 -0800593ALL_MODULES.$(LOCAL_MODULE).EVENT_LOG_TAGS := \
594 $(ALL_MODULES.$(LOCAL_MODULE).EVENT_LOG_TAGS) $(event_log_tags)
Joe Onorato77dc0a52010-05-17 18:16:11 -0700595ALL_MODULES.$(LOCAL_MODULE).INTERMEDIATE_SOURCE_DIR := \
Ying Wang01c35172010-05-17 19:07:21 -0700596 $(ALL_MODULES.$(LOCAL_MODULE).INTERMEDIATE_SOURCE_DIR) $(LOCAL_INTERMEDIATE_SOURCE_DIR)
Joe Onoratoe2139442012-05-22 17:33:22 -0700597ALL_MODULES.$(LOCAL_MODULE).MAKEFILE := \
598 $(ALL_MODULES.$(LOCAL_MODULE).MAKEFILE) $(LOCAL_MODULE_MAKEFILE)
Ying Wangdbb31be2011-12-09 15:11:57 -0800599ifdef LOCAL_MODULE_OWNER
600ALL_MODULES.$(LOCAL_MODULE).OWNER := \
Ying Wangfb03fb32012-10-03 15:22:51 -0700601 $(sort $(ALL_MODULES.$(LOCAL_MODULE).OWNER) $(LOCAL_MODULE_OWNER))
Ying Wangdbb31be2011-12-09 15:11:57 -0800602endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800603
Joe Onorato8a06bac2010-05-21 14:29:29 -0700604INSTALLABLE_FILES.$(LOCAL_INSTALLED_MODULE).MODULE := $(LOCAL_MODULE)
605
The Android Open Source Project88b60792009-03-03 19:28:42 -0800606###########################################################
607## Take care of LOCAL_MODULE_TAGS
608###########################################################
609
610# Keep track of all the tags we've seen.
611ALL_MODULE_TAGS := $(sort $(ALL_MODULE_TAGS) $(LOCAL_MODULE_TAGS))
612
613# Add this module to the tag list of each specified tag.
614# Don't use "+=". If the variable hasn't been set with ":=",
615# it will default to recursive expansion.
616$(foreach tag,$(LOCAL_MODULE_TAGS),\
617 $(eval ALL_MODULE_TAGS.$(tag) := \
Ying Wang1d977e32013-01-30 11:22:06 -0800618 $(ALL_MODULE_TAGS.$(tag)) \
619 $(LOCAL_INSTALLED_MODULE)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800620
621# Add this module name to the tag list of each specified tag.
622$(foreach tag,$(LOCAL_MODULE_TAGS),\
623 $(eval ALL_MODULE_NAME_TAGS.$(tag) += $(LOCAL_MODULE)))
624
The Android Open Source Project88b60792009-03-03 19:28:42 -0800625###########################################################
Ying Wangef4d82f2013-01-29 16:59:18 -0800626## umbrella targets used to verify builds
627###########################################################
Ying Wangef4d82f2013-01-29 16:59:18 -0800628j_or_n :=
629ifneq (,$(filter EXECUTABLES SHARED_LIBRARIES STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS)))
630j_or_n := native
631else
632ifneq (,$(filter JAVA_LIBRARIES APPS,$(LOCAL_MODULE_CLASS)))
633j_or_n := java
Ying Wangef4d82f2013-01-29 16:59:18 -0800634endif
635endif
636ifdef LOCAL_IS_HOST_MODULE
637h_or_t := host
638else
639h_or_t := target
640endif
641
642ifdef j_or_n
Ying Wang1d977e32013-01-30 11:22:06 -0800643$(j_or_n) $(h_or_t) $(j_or_n)-$(h_or_t) : $(LOCAL_CHECKED_MODULE)
Ying Wangef4d82f2013-01-29 16:59:18 -0800644ifneq (,$(filter $(LOCAL_MODULE_TAGS),tests))
Ying Wang1d977e32013-01-30 11:22:06 -0800645$(j_or_n)-$(h_or_t)-tests $(j_or_n)-tests $(h_or_t)-tests : $(LOCAL_CHECKED_MODULE)
Ying Wangef4d82f2013-01-29 16:59:18 -0800646endif
647endif
648
649###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800650## NOTICE files
651###########################################################
652
Ying Wang13d69502012-11-01 17:22:33 -0700653include $(BUILD_NOTICE_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800654
655#:vi noexpandtab