blob: 242b53d5562120207926663200e9eca53da1a9a1 [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
37 my_prefix:=HOST_
38 my_host:=host-
39else
40 my_prefix:=TARGET_
41 my_host:=
42endif
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
53#comma := ,
54#empty :=
55#space := $(empty) $(empty)
56#$(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)
57
58LOCAL_MODULE_TAGS := $(sort $(LOCAL_MODULE_TAGS))
59ifeq (,$(LOCAL_MODULE_TAGS))
Ying Wang2fd81cf2010-12-10 11:17:28 -080060ifeq (true,$(LOCAL_UNINSTALLABLE_MODULE))
61LOCAL_MODULE_TAGS := optional
62else
63# Installable modules without tags fall back to user (which is changed to user eng below)
The Android Open Source Project88b60792009-03-03 19:28:42 -080064LOCAL_MODULE_TAGS := user
Ying Wang2fd81cf2010-12-10 11:17:28 -080065endif
Jean-Baptiste Queru423c15c2010-09-14 13:27:12 -070066#$(warning default tags: $(lastword $(filter-out config/% out/%,$(MAKEFILE_LIST))))
The Android Open Source Project88b60792009-03-03 19:28:42 -080067endif
68
Jean-Baptiste Querua831cbd2010-01-07 11:06:50 -080069# Only the tags mentioned in this test are expected to be set by module
70# makefiles. Anything else is either a typo or a source of unexpected
71# behaviors.
Thorsten Glaser2213aab2010-06-03 19:57:02 +020072ifneq ($(filter-out user debug eng tests optional samples shell_ash shell_mksh,$(LOCAL_MODULE_TAGS)),)
Jean-Baptiste Querua831cbd2010-01-07 11:06:50 -080073$(warning unusual tags $(LOCAL_MODULE_TAGS) on $(LOCAL_MODULE) at $(LOCAL_PATH))
74endif
75
Jean-Baptiste Queru4074f232010-09-03 16:32:58 -070076ifneq ($(filter $(LOCAL_MODULE_TAGS),user),)
77 ifeq ($(filter $(GRANDFATHERED_USER_MODULES),$(LOCAL_MODULE)),)
Jean-Baptiste Querud64e5a22010-09-14 08:59:21 -070078 $(warning *** Module name: $(LOCAL_MODULE))
79 $(warning *** Makefile location: $(LOCAL_PATH))
Jean-Baptiste Queru58906002010-09-15 13:59:29 -070080 $(warning * )
81 $(warning * Each module must use a LOCAL_MODULE_TAGS in its)
82 $(warning * Android.mk. Possible tags declared by a module:)
83 $(warning * )
84 $(warning * optional, debug, eng, tests, samples)
85 $(warning * )
86 $(warning * If the module is expected to be in all builds)
87 $(warning * of a product, then it should use the)
88 $(warning * "optional" tag: )
89 $(warning * )
90 $(warning * Add "LOCAL_MODULE_TAGS := optional" in the)
91 $(warning * Android.mk for the affected module, and add)
92 $(warning * the LOCAL_MODULE value for that component)
93 $(warning * into the PRODUCT_PACKAGES section of product)
94 $(warning * makefile(s) where it's necessary, if)
95 $(warning * appropriate.)
96 $(warning * )
97 $(warning * If the component should be in EVERY build of ALL)
98 $(warning * products, then add its LOCAL_MODULE value to the)
99 $(warning * PRODUCT_PACKAGES section of)
100 $(warning * build/target/product/core.mk)
101 $(warning * )
Jean-Baptiste Querud64e5a22010-09-14 08:59:21 -0700102 $(error user tag detected on new module - user tags are only supported on legacy modules)
Jean-Baptiste Queru4074f232010-09-03 16:32:58 -0700103 endif
104endif
105
The Android Open Source Project88b60792009-03-03 19:28:42 -0800106# Add implicit tags.
107#
108# If the local directory or one of its parents contains a MODULE_LICENSE_GPL
Ying Wanga67ce692011-03-03 13:29:38 -0800109# 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 -0800110# find files like MODULE_LICENSE_GPL_AND_AFL but exclude files like
111# MODULE_LICENSE_LGPL.
112#
Ying Wanga67ce692011-03-03 13:29:38 -0800113ifneq ($(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*_GPL* MODULE_LICENSE*_MPL*),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800114 LOCAL_MODULE_TAGS += gnu
115endif
116
117#
118# If this module is listed on CUSTOM_MODULES, promote it to "user"
119# so that it will be installed in $(TARGET_OUT).
120#
121ifneq (,$(filter $(LOCAL_MODULE),$(CUSTOM_MODULES)))
122 LOCAL_MODULE_TAGS := $(sort $(LOCAL_MODULE_TAGS) user)
123endif
124
The Android Open Source Project88b60792009-03-03 19:28:42 -0800125ifdef LOCAL_IS_HOST_MODULE
Ying Wang8f779362011-09-13 13:57:26 -0700126 partition_tag :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800127else
Ying Wang8f779362011-09-13 13:57:26 -0700128ifeq (true,$(LOCAL_PROPRIETARY_MODULE))
129 partition_tag := _VENDOR
130else
131 # The definition of should-install-to-system will be different depending
132 # on which goal (e.g., sdk or just droid) is being built.
133 partition_tag := $(if $(call should-install-to-system,$(LOCAL_MODULE_TAGS)),,_DATA)
134endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800135endif
136
137LOCAL_MODULE_CLASS := $(strip $(LOCAL_MODULE_CLASS))
138ifneq ($(words $(LOCAL_MODULE_CLASS)),1)
139 $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS must contain exactly one word, not "$(LOCAL_MODULE_CLASS)")
140endif
141
Jean-Baptiste Queru6907cfe2010-01-07 11:19:39 -0800142# Those used to be implicitly ignored, but aren't any more.
143# As of 20100110 there are no apps with the user tag.
144ifeq ($(LOCAL_MODULE_CLASS),APPS)
145 ifneq ($(filter $(LOCAL_MODULE_TAGS),user),)
146 $(warning user tag on app $(LOCAL_MODULE) at $(LOCAL_PATH) - add your app to core.mk instead)
147 endif
148endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800149
150LOCAL_MODULE_PATH := $(strip $(LOCAL_MODULE_PATH))
151ifeq ($(LOCAL_MODULE_PATH),)
Ying Wang8f779362011-09-13 13:57:26 -0700152 LOCAL_MODULE_PATH := $($(my_prefix)OUT$(partition_tag)_$(LOCAL_MODULE_CLASS))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800153 ifeq ($(strip $(LOCAL_MODULE_PATH)),)
154 $(error $(LOCAL_PATH): unhandled LOCAL_MODULE_CLASS "$(LOCAL_MODULE_CLASS)")
155 endif
156endif
157
158ifneq ($(strip $(LOCAL_BUILT_MODULE)$(LOCAL_INSTALLED_MODULE)),)
159 $(error $(LOCAL_PATH): LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE must not be defined by component makefiles)
160endif
161
162# Make sure that this IS_HOST/CLASS/MODULE combination is unique.
163module_id := MODULE.$(if \
164 $(LOCAL_IS_HOST_MODULE),HOST,TARGET).$(LOCAL_MODULE_CLASS).$(LOCAL_MODULE)
165ifdef $(module_id)
166$(error $(LOCAL_PATH): $(module_id) already defined by $($(module_id)))
167endif
168$(module_id) := $(LOCAL_PATH)
169
170intermediates := $(call local-intermediates-dir)
171intermediates.COMMON := $(call local-intermediates-dir,COMMON)
172
173###########################################################
174# Pick a name for the intermediate and final targets
175###########################################################
176LOCAL_MODULE_STEM := $(strip $(LOCAL_MODULE_STEM))
177ifeq ($(LOCAL_MODULE_STEM),)
178 LOCAL_MODULE_STEM := $(LOCAL_MODULE)
179endif
180LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE_STEM)$(LOCAL_MODULE_SUFFIX)
181
182LOCAL_BUILT_MODULE_STEM := $(strip $(LOCAL_BUILT_MODULE_STEM))
183ifeq ($(LOCAL_BUILT_MODULE_STEM),)
184 LOCAL_BUILT_MODULE_STEM := $(LOCAL_INSTALLED_MODULE_STEM)
185endif
186
187# OVERRIDE_BUILT_MODULE_PATH is only allowed to be used by the
188# internal SHARED_LIBRARIES build files.
189OVERRIDE_BUILT_MODULE_PATH := $(strip $(OVERRIDE_BUILT_MODULE_PATH))
190ifdef OVERRIDE_BUILT_MODULE_PATH
191 ifneq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
192 $(error $(LOCAL_PATH): Illegal use of OVERRIDE_BUILT_MODULE_PATH)
193 endif
194 built_module_path := $(OVERRIDE_BUILT_MODULE_PATH)
195else
196 built_module_path := $(intermediates)
197endif
198LOCAL_BUILT_MODULE := $(built_module_path)/$(LOCAL_BUILT_MODULE_STEM)
199built_module_path :=
200
The Android Open Source Project88b60792009-03-03 19:28:42 -0800201LOCAL_UNINSTALLABLE_MODULE := $(strip $(LOCAL_UNINSTALLABLE_MODULE))
Ying Wang162991b2011-09-07 10:21:42 -0700202ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
Jeff Brown703e7c62011-02-04 20:15:00 -0800203 LOCAL_INSTALLED_MODULE := $(LOCAL_MODULE_PATH)/$(LOCAL_INSTALLED_MODULE_STEM)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800204endif
205
206# Assemble the list of targets to create PRIVATE_ variables for.
207LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE)
208
209
210###########################################################
211## AIDL: Compile .aidl files to .java
212###########################################################
213
214aidl_sources := $(filter %.aidl,$(LOCAL_SRC_FILES))
215
216ifneq ($(strip $(aidl_sources)),)
217
218aidl_java_sources := $(patsubst %.aidl,%.java,$(addprefix $(intermediates.COMMON)/src/, $(aidl_sources)))
219aidl_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(aidl_sources))
220
Ying Wang1214aeb2010-12-14 10:57:54 -0800221ifeq (,$(TARGET_BUILD_APPS))
222LOCAL_AIDL_INCLUDES += $(FRAMEWORKS_BASE_JAVA_SRC_DIRS)
223endif
Ying Wange3265fb2010-01-25 09:56:41 -0800224aidl_preprocess_import :=
225LOCAL_SDK_VERSION:=$(strip $(LOCAL_SDK_VERSION))
226ifdef LOCAL_SDK_VERSION
Ying Wanga07d37b2010-06-09 11:43:33 -0700227ifeq ($(LOCAL_SDK_VERSION),current)
228 aidl_preprocess_import := $(TARGET_OUT_COMMON_INTERMEDIATES)/framework.aidl
229else
230 aidl_preprocess_import := $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_VERSION)/framework.aidl
Ying Wange3265fb2010-01-25 09:56:41 -0800231endif # !current
232endif # LOCAL_SDK_VERSION
Ying Wanga07d37b2010-06-09 11:43:33 -0700233$(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 -0800234
Ying Wanga7d9ca32011-07-13 14:29:33 -0700235$(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 -0800236 $(transform-aidl-to-java)
237-include $(aidl_java_sources:%.java=%.P)
238
239else
240aidl_java_sources :=
241endif
242
243###########################################################
Doug Zongker9bd49622009-11-30 14:28:59 -0800244## logtags: Add .logtags files to global list, emit java source
245###########################################################
246
247logtags_sources := $(filter %.logtags,$(LOCAL_SRC_FILES))
248
249ifneq ($(strip $(logtags_sources)),)
250
251event_log_tags := $(addprefix $(LOCAL_PATH)/,$(logtags_sources))
252
253# Emit a java source file with constants for the tags, if
254# LOCAL_MODULE_CLASS is "APPS" or "JAVA_LIBRARIES".
255ifneq ($(strip $(filter $(LOCAL_MODULE_CLASS),APPS JAVA_LIBRARIES)),)
256
257logtags_java_sources := $(patsubst %.logtags,%.java,$(addprefix $(intermediates.COMMON)/src/, $(logtags_sources)))
258logtags_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(logtags_sources))
259
Joe Onoratob7510532010-07-14 10:22:54 -0700260$(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 -0800261 $(transform-logtags-to-java)
262
263endif
264
265else
266logtags_java_sources :=
267event_log_tags :=
268endif
269
270###########################################################
Ying Wanga5fc87a2010-11-02 18:43:16 -0700271## .proto files: Compile proto files to .java
272###########################################################
273proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES))
274# Because names of the .java files compiled from .proto files are unknown until the
275# .proto files are compiled, we use a timestamp file as depedency.
276proto_java_sources_file_stamp :=
277ifneq ($(proto_sources),)
278proto_sources_fullpath := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(proto_sources))
279# By putting the generated java files into $(LOCAL_INTERMEDIATE_SOURCE_DIR), they will be
280# automatically found by the java compiling function transform-java-to-classes.jar.
Ying Wang60293912010-11-05 11:20:03 -0700281ifneq ($(LOCAL_INTERMEDIATE_SOURCE_DIR),)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700282proto_java_intemediate_dir := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/proto
Ying Wang60293912010-11-05 11:20:03 -0700283else
284# LOCAL_INTERMEDIATE_SOURCE_DIR may be not defined in non-java modules.
285proto_java_intemediate_dir := $(intermediates)/proto
286endif
Ying Wanga5fc87a2010-11-02 18:43:16 -0700287proto_java_sources_file_stamp := $(proto_java_intemediate_dir)/Proto.stamp
288proto_java_sources_dir := $(proto_java_intemediate_dir)/src
289
290$(proto_java_sources_file_stamp): PRIVATE_PROTO_INCLUDES := $(TOP)
291$(proto_java_sources_file_stamp): PRIVATE_PROTO_SRC_FILES := $(proto_sources_fullpath)
292$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_DIR := $(proto_java_sources_dir)
293ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro)
294$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javamicro_out
295else
296$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --java_out
297endif
Ying Wang33c0d952010-11-05 11:30:58 -0700298$(proto_java_sources_file_stamp): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700299$(proto_java_sources_file_stamp) : $(proto_sources_fullpath) $(PROTOC)
300 $(call transform-proto-to-java)
301
302#TODO: protoc should output the dependencies introduced by imports.
303
304LOCAL_INTERMEDIATE_TARGETS += $(proto_java_sources_file_stamp)
305endif # proto_sources
306
307
308###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800309## Java: Compile .java files to .class
310###########################################################
311#TODO: pull this into java.make once host and target are combined
312
Ying Wang52911302010-05-26 13:13:56 -0700313java_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) $(aidl_java_sources) $(logtags_java_sources) \
314 $(filter %.java,$(LOCAL_GENERATED_SOURCES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800315all_java_sources := $(java_sources) $(addprefix $($(my_prefix)OUT_COMMON_INTERMEDIATES)/, $(filter %.java,$(LOCAL_INTERMEDIATE_SOURCES)))
316
317## Java resources #########################################
318
319# Look for resource files in any specified directories.
320# Non-java and non-doc files will be picked up as resources
321# and included in the output jar file.
322java_resource_file_groups :=
323
324LOCAL_JAVA_RESOURCE_DIRS := $(strip $(LOCAL_JAVA_RESOURCE_DIRS))
325ifneq ($(LOCAL_JAVA_RESOURCE_DIRS),)
326 # This makes a list of words like
327 # <dir1>::<file1>:<file2> <dir2>::<file1> <dir3>:
328 # where each of the files is relative to the directory it's grouped with.
329 # Directories that don't contain any resource files will result in groups
330 # that end with a colon, and they are stripped out in the next step.
331 java_resource_file_groups += \
332 $(foreach dir,$(LOCAL_JAVA_RESOURCE_DIRS), \
333 $(subst $(space),:,$(strip \
334 $(TOP_DIR)$(LOCAL_PATH)/$(dir): \
335 $(patsubst ./%,%,$(shell cd $(TOP_DIR)$(LOCAL_PATH)/$(dir) && \
336 find . \
337 -type d -a -name ".svn" -prune -o \
338 -type f \
339 -a \! -name "*.java" \
340 -a \! -name "package.html" \
341 -a \! -name "overview.html" \
342 -a \! -name ".*.swp" \
343 -a \! -name ".DS_Store" \
344 -a \! -name "*~" \
345 -print \
346 )) \
347 )) \
348 )
349 java_resource_file_groups := $(filter-out %:,$(java_resource_file_groups))
350endif # LOCAL_JAVA_RESOURCE_DIRS
351
352LOCAL_JAVA_RESOURCE_FILES := $(strip $(LOCAL_JAVA_RESOURCE_FILES))
353ifneq ($(LOCAL_JAVA_RESOURCE_FILES),)
354 java_resource_file_groups += \
355 $(foreach f,$(LOCAL_JAVA_RESOURCE_FILES), \
356 $(patsubst %/,%,$(dir $(f)))::$(notdir $(f)) \
357 )
358endif # LOCAL_JAVA_RESOURCE_FILES
359
360ifdef java_resource_file_groups
361 # The full paths to all resources, used for dependencies.
362 java_resource_sources := \
363 $(foreach group,$(java_resource_file_groups), \
364 $(addprefix $(word 1,$(subst :,$(space),$(group)))/, \
365 $(wordlist 2,9999,$(subst :,$(space),$(group))) \
366 ) \
367 )
368 # The arguments to jar that will include these files in a jar file.
Ying Wang194a8ec2011-06-06 14:34:52 -0700369 # Quote the file name to handle special characters (such as #) correctly.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800370 extra_jar_args := \
371 $(foreach group,$(java_resource_file_groups), \
Ying Wang194a8ec2011-06-06 14:34:52 -0700372 $(addprefix -C "$(word 1,$(subst :,$(space),$(group)))" , \
373 $(foreach w, $(wordlist 2,9999,$(subst :,$(space),$(group))), "$(w)" ) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800374 ) \
375 )
376 java_resource_file_groups :=
377else
378 java_resource_sources :=
379 extra_jar_args :=
380endif # java_resource_file_groups
381
382## PRIVATE java vars ######################################
383
384ifneq ($(strip $(all_java_sources)$(all_res_assets)),)
385
386full_static_java_libs := \
387 $(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES), \
388 $(call intermediates-dir-for, \
Ying Wanga83940f2010-09-24 18:09:04 -0700389 JAVA_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),COMMON)/javalib.jar)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800390
391$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_INSTALL_DIR := $(dir $(LOCAL_INSTALLED_MODULE))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800392$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates)/classes
393$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates)/src
394$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAVA_SOURCES := $(all_java_sources)
395$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAVA_OBJECTS := $(patsubst %.java,%.class,$(LOCAL_SRC_FILES))
396ifeq ($(my_prefix),TARGET_)
Joe Onoratoe62902c2009-09-23 15:28:12 -0700397ifeq ($(LOCAL_SDK_VERSION),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800398$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,core)
Ying Wanga07d37b2010-06-09 11:43:33 -0700399else
400ifeq ($(LOCAL_SDK_VERSION),current)
401$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,android_stubs_current)
402else
403$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,sdk_v$(LOCAL_SDK_VERSION))
404endif # current
405endif # LOCAL_SDK_VERSION
406endif # TARGET_
The Android Open Source Project88b60792009-03-03 19:28:42 -0800407$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR)
408$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args)
409$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASSET_DIR := $(LOCAL_ASSET_DIR)
410$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_STATIC_JAVA_LIBRARIES := $(full_static_java_libs)
411
412# full_java_libs: The list of files that should be used as the classpath.
413# Using this list as a dependency list WILL NOT WORK.
414# full_java_lib_deps: Should be specified as a prerequisite of this module
415# to guarantee that the files in full_java_libs will
416# be up-to-date.
417ifdef LOCAL_IS_HOST_MODULE
Ying Wang73ca57f2010-09-10 18:38:10 -0700418ifeq ($(LOCAL_BUILD_HOST_DEX),true)
Ying Wang015edd22011-01-20 15:01:56 -0800419$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,core-hostdex,$(LOCAL_IS_HOST_MODULE))
420
Ying Wang73ca57f2010-09-10 18:38:10 -0700421full_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
422full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
423else
Ying Wang015edd22011-01-20 15:01:56 -0800424$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH :=
425
The Android Open Source Project88b60792009-03-03 19:28:42 -0800426full_java_libs := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/,$(addsuffix $(COMMON_JAVA_PACKAGE_SUFFIX),$(LOCAL_JAVA_LIBRARIES)))
427full_java_lib_deps := $(full_java_libs)
Ying Wang73ca57f2010-09-10 18:38:10 -0700428endif # LOCAL_BUILD_HOST_DEX
The Android Open Source Project88b60792009-03-03 19:28:42 -0800429else
430full_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
431full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
Ying Wange3265fb2010-01-25 09:56:41 -0800432endif # !LOCAL_IS_HOST_MODULE
The Android Open Source Project88b60792009-03-03 19:28:42 -0800433full_java_libs += $(full_static_java_libs) $(LOCAL_CLASSPATH)
434full_java_lib_deps += $(full_static_java_libs) $(LOCAL_CLASSPATH)
435
436# This is set by packages that contain instrumentation, allowing them to
437# link against the package they are instrumenting. Currently only one such
438# package is allowed.
439LOCAL_INSTRUMENTATION_FOR := $(strip $(LOCAL_INSTRUMENTATION_FOR))
440ifdef LOCAL_INSTRUMENTATION_FOR
441 ifneq ($(words $(LOCAL_INSTRUMENTATION_FOR)),1)
442 $(error \
443 $(LOCAL_PATH): Multiple LOCAL_INSTRUMENTATION_FOR members defined)
444 endif
445
446 link_instr_intermediates_dir := $(call intermediates-dir-for, \
447 APPS,$(LOCAL_INSTRUMENTATION_FOR))
448 link_instr_intermediates_dir.COMMON := $(call intermediates-dir-for, \
449 APPS,$(LOCAL_INSTRUMENTATION_FOR),,COMMON)
450
Ying Wang3b2bdf12010-02-01 09:51:23 -0800451 # link against the jar with full original names (before proguard processing).
Ying Wanga9c381e2010-10-02 18:35:51 -0700452 full_java_libs += $(link_instr_intermediates_dir.COMMON)/classes.jar
453 full_java_lib_deps += $(link_instr_intermediates_dir.COMMON)/classes.jar
The Android Open Source Project88b60792009-03-03 19:28:42 -0800454endif
455
Ying Wangc06243d2010-04-26 20:09:56 -0700456jar_manifest_file :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800457ifneq ($(strip $(LOCAL_JAR_MANIFEST)),)
Ying Wangc06243d2010-04-26 20:09:56 -0700458jar_manifest_file := $(LOCAL_PATH)/$(LOCAL_JAR_MANIFEST)
459$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST := $(jar_manifest_file)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800460else
461$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST :=
462endif
463
464endif
465
466
467###########################################################
468## make clean- targets
469###########################################################
470cleantarget := clean-$(LOCAL_MODULE)
471$(cleantarget) : PRIVATE_MODULE := $(LOCAL_MODULE)
472$(cleantarget) : PRIVATE_CLEAN_FILES := \
473 $(PRIVATE_CLEAN_FILES) \
474 $(LOCAL_BUILT_MODULE) \
475 $(LOCAL_INSTALLED_MODULE) \
476 $(intermediates)
477$(cleantarget)::
478 @echo "Clean: $(PRIVATE_MODULE)"
479 $(hide) rm -rf $(PRIVATE_CLEAN_FILES)
480
481###########################################################
482## Common definitions for module.
483###########################################################
484
485# Propagate local configuration options to this target.
486$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PATH:=$(LOCAL_PATH)
487$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_POST_PROCESS_COMMAND:= $(LOCAL_POST_PROCESS_COMMAND)
488$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_AAPT_FLAGS:= $(LOCAL_AAPT_FLAGS)
489$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_JAVA_LIBRARIES:= $(LOCAL_JAVA_LIBRARIES)
Jeff Hamiltonbb67d212010-02-05 22:36:42 -0600490$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MANIFEST_PACKAGE_NAME:= $(LOCAL_MANIFEST_PACKAGE_NAME)
Ying Wang3dae0ee2010-09-02 15:41:01 -0700491$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MANIFEST_INSTRUMENTATION_FOR:= $(LOCAL_MANIFEST_INSTRUMENTATION_FOR)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800492
493$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_ALL_JAVA_LIBRARIES:= $(full_java_libs)
494$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_IS_HOST_MODULE := $(LOCAL_IS_HOST_MODULE)
495$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_HOST:= $(my_host)
496
Dima Zavin46e9bec2009-05-27 19:41:07 -0700497$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_INTERMEDIATES_DIR:= $(intermediates)
498
The Android Open Source Project88b60792009-03-03 19:28:42 -0800499# Tell the module and all of its sub-modules who it is.
500$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MODULE:= $(LOCAL_MODULE)
501
502# Provide a short-hand for building this module.
503# We name both BUILT and INSTALLED in case
504# LOCAL_UNINSTALLABLE_MODULE is set.
505.PHONY: $(LOCAL_MODULE)
506$(LOCAL_MODULE): $(LOCAL_BUILT_MODULE) $(LOCAL_INSTALLED_MODULE)
507
508###########################################################
509## Module installation rule
510###########################################################
511
512# Some hosts do not have ACP; override the LOCAL version if that's the case.
513ifneq ($(strip $(HOST_ACP_UNAVAILABLE)),)
514 LOCAL_ACP_UNAVAILABLE := $(strip $(HOST_ACP_UNAVAILABLE))
515endif
516
517ifndef LOCAL_UNINSTALLABLE_MODULE
518 # Define a copy rule to install the module.
519 # acp and libraries that it uses can't use acp for
520 # installation; hence, LOCAL_ACP_UNAVAILABLE.
521ifneq ($(LOCAL_ACP_UNAVAILABLE),true)
522$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE) | $(ACP)
523 @echo "Install: $@"
Ying Wang84ed6fa2011-01-18 17:21:20 -0800524 $(copy-file-to-new-target)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800525else
526$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE)
527 @echo "Install: $@"
528 $(copy-file-to-target-with-cp)
529endif
530
Ying Wang79e3dec2011-10-24 12:17:03 -0700531ifdef LOCAL_DEX_PREOPT
Ying Wange7874c42010-09-17 16:36:06 -0700532installed_odex := $(basename $(LOCAL_INSTALLED_MODULE)).odex
533built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex
534$(installed_odex) : $(built_odex) | $(ACP)
535 @echo "Install: $@"
536 $(copy-file-to-target)
537
Ying Wang84ed6fa2011-01-18 17:21:20 -0800538$(LOCAL_INSTALLED_MODULE) : $(installed_odex)
Ying Wange7874c42010-09-17 16:36:06 -0700539endif
540
The Android Open Source Project88b60792009-03-03 19:28:42 -0800541endif # !LOCAL_UNINSTALLABLE_MODULE
542
Joe Onoratoe334d252009-07-17 15:33:40 -0400543
544###########################################################
545## CHECK_BUILD goals
546###########################################################
547
548# If nobody has defined a more specific module for the
549# checked modules, use LOCAL_BUILT_MODULE. This was old
550# behavior, so it should be a safe default.
551ifndef LOCAL_CHECKED_MODULE
Joe Onorato05c7f612010-01-05 12:47:14 -0800552 ifndef LOCAL_SDK_VERSION
553 LOCAL_CHECKED_MODULE := $(LOCAL_BUILT_MODULE)
554 endif
Joe Onoratoe334d252009-07-17 15:33:40 -0400555endif
556
557# If they request that this module not be checked, then don't.
558# PLEASE DON'T SET THIS. ANY PLACES THAT SET THIS WITHOUT
559# GOOD REASON WILL HAVE IT REMOVED.
560ifdef LOCAL_DONT_CHECK_MODULE
561 LOCAL_CHECKED_MODULE :=
562endif
563
The Android Open Source Project88b60792009-03-03 19:28:42 -0800564###########################################################
565## Register with ALL_MODULES
566###########################################################
567
568ALL_MODULES += $(LOCAL_MODULE)
569
570# Don't use += on subvars, or else they'll end up being
571# recursively expanded.
Joe Onorato8a06bac2010-05-21 14:29:29 -0700572ALL_MODULES.$(LOCAL_MODULE).CLASS := \
573 $(ALL_MODULES.$(LOCAL_MODULE).CLASS) $(LOCAL_MODULE_CLASS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800574ALL_MODULES.$(LOCAL_MODULE).PATH := \
575 $(ALL_MODULES.$(LOCAL_MODULE).PATH) $(LOCAL_PATH)
576ALL_MODULES.$(LOCAL_MODULE).TAGS := \
577 $(ALL_MODULES.$(LOCAL_MODULE).TAGS) $(LOCAL_MODULE_TAGS)
Joe Onoratoe334d252009-07-17 15:33:40 -0400578ALL_MODULES.$(LOCAL_MODULE).CHECKED := \
579 $(ALL_MODULES.$(LOCAL_MODULE).CHECKED) $(LOCAL_CHECKED_MODULE)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800580ALL_MODULES.$(LOCAL_MODULE).BUILT := \
581 $(ALL_MODULES.$(LOCAL_MODULE).BUILT) $(LOCAL_BUILT_MODULE)
582ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
583 $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(LOCAL_INSTALLED_MODULE)
584ALL_MODULES.$(LOCAL_MODULE).REQUIRED := \
585 $(ALL_MODULES.$(LOCAL_MODULE).REQUIRED) $(LOCAL_REQUIRED_MODULES)
Doug Zongker9bd49622009-11-30 14:28:59 -0800586ALL_MODULES.$(LOCAL_MODULE).EVENT_LOG_TAGS := \
587 $(ALL_MODULES.$(LOCAL_MODULE).EVENT_LOG_TAGS) $(event_log_tags)
Joe Onorato77dc0a52010-05-17 18:16:11 -0700588ALL_MODULES.$(LOCAL_MODULE).INTERMEDIATE_SOURCE_DIR := \
Ying Wang01c35172010-05-17 19:07:21 -0700589 $(ALL_MODULES.$(LOCAL_MODULE).INTERMEDIATE_SOURCE_DIR) $(LOCAL_INTERMEDIATE_SOURCE_DIR)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800590
Joe Onorato8a06bac2010-05-21 14:29:29 -0700591INSTALLABLE_FILES.$(LOCAL_INSTALLED_MODULE).MODULE := $(LOCAL_MODULE)
592
The Android Open Source Project88b60792009-03-03 19:28:42 -0800593###########################################################
594## Take care of LOCAL_MODULE_TAGS
595###########################################################
596
597# Keep track of all the tags we've seen.
598ALL_MODULE_TAGS := $(sort $(ALL_MODULE_TAGS) $(LOCAL_MODULE_TAGS))
599
600# Add this module to the tag list of each specified tag.
601# Don't use "+=". If the variable hasn't been set with ":=",
602# it will default to recursive expansion.
603$(foreach tag,$(LOCAL_MODULE_TAGS),\
604 $(eval ALL_MODULE_TAGS.$(tag) := \
605 $(ALL_MODULE_TAGS.$(tag)) \
606 $(LOCAL_INSTALLED_MODULE)))
607
608# Add this module name to the tag list of each specified tag.
609$(foreach tag,$(LOCAL_MODULE_TAGS),\
610 $(eval ALL_MODULE_NAME_TAGS.$(tag) += $(LOCAL_MODULE)))
611
The Android Open Source Project88b60792009-03-03 19:28:42 -0800612###########################################################
613## NOTICE files
614###########################################################
615
616include $(BUILD_SYSTEM)/notice_files.mk
617
618#:vi noexpandtab