2 # Copyright (C) 2008 The Android Open Source Project
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 # Users can define base-rules-hook in their buildspec.mk to perform
18 # arbitrary operations as each module is included.
20 $(if $(base-rules-hook),)
23 ###########################################################
24 ## Common instructions for a generic module.
25 ###########################################################
27 LOCAL_MODULE := $(strip $(LOCAL_MODULE))
28 ifeq ($(LOCAL_MODULE),)
29 $(error $(LOCAL_PATH): LOCAL_MODULE is not defined)
32 LOCAL_IS_HOST_MODULE := $(strip $(LOCAL_IS_HOST_MODULE))
33 ifdef 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)")
44 ###########################################################
45 ## Validate and define fallbacks for input LOCAL_* variables.
46 ###########################################################
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
53 #$(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)
55 LOCAL_UNINSTALLABLE_MODULE := $(strip $(LOCAL_UNINSTALLABLE_MODULE))
56 LOCAL_MODULE_TAGS := $(sort $(LOCAL_MODULE_TAGS))
57 ifeq (,$(LOCAL_MODULE_TAGS))
58 LOCAL_MODULE_TAGS := optional
61 # User tags are not allowed anymore. Fail early because it will not be installed
63 ifneq ($(filter $(LOCAL_MODULE_TAGS),user),)
64 $(warning *** Module name: $(LOCAL_MODULE))
65 $(warning *** Makefile location: $(LOCAL_MODULE_MAKEFILE))
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.)
72 $(error user tag detected on module.)
75 # 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
78 ifneq ($(filter-out debug eng tests optional samples shell_ash shell_mksh,$(LOCAL_MODULE_TAGS)),)
79 $(warning unusual tags $(LOCAL_MODULE_TAGS) on $(LOCAL_MODULE) at $(LOCAL_PATH))
84 # If the local directory or one of its parents contains a MODULE_LICENSE_GPL
85 # file, tag the module as "gnu". Search for "*_GPL*" and "*_MPL*" so that we can also
86 # find files like MODULE_LICENSE_GPL_AND_AFL but exclude files like
87 # MODULE_LICENSE_LGPL.
89 gpl_license_file := $(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*_GPL* MODULE_LICENSE*_MPL*)
90 ifneq ($(gpl_license_file),)
91 LOCAL_MODULE_TAGS += gnu
92 ALL_GPL_MODULE_LICENSE_FILES := $(sort $(ALL_GPL_MODULE_LICENSE_FILES) $(gpl_license_file))
95 LOCAL_MODULE_CLASS := $(strip $(LOCAL_MODULE_CLASS))
96 ifneq ($(words $(LOCAL_MODULE_CLASS)),1)
97 $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS must contain exactly one word, not "$(LOCAL_MODULE_CLASS)")
100 ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
101 LOCAL_MODULE_PATH := $(strip $(LOCAL_MODULE_PATH))
102 ifeq ($(LOCAL_MODULE_PATH),)
103 ifdef LOCAL_IS_HOST_MODULE
106 ifeq (true,$(LOCAL_PROPRIETARY_MODULE))
107 partition_tag := _VENDOR
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)
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
119 LOCAL_MODULE_PATH := $($(install_path_var))
120 ifeq ($(strip $(LOCAL_MODULE_PATH)),)
121 $(error $(LOCAL_PATH): unhandled install path "$(install_path_var)")
124 endif # not LOCAL_UNINSTALLABLE_MODULE
126 ifneq ($(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)
130 # Make sure that this IS_HOST/CLASS/MODULE combination is unique.
131 module_id := MODULE.$(if \
132 $(LOCAL_IS_HOST_MODULE),HOST,TARGET).$(LOCAL_MODULE_CLASS).$(LOCAL_MODULE)
134 $(error $(LOCAL_PATH): $(module_id) already defined by $($(module_id)))
136 $(module_id) := $(LOCAL_PATH)
138 intermediates := $(call local-intermediates-dir)
139 intermediates.COMMON := $(call local-intermediates-dir,COMMON)
141 ###########################################################
142 # Pick a name for the intermediate and final targets
143 ###########################################################
144 LOCAL_MODULE_STEM := $(strip $(LOCAL_MODULE_STEM))
145 ifeq ($(LOCAL_MODULE_STEM),)
146 LOCAL_MODULE_STEM := $(LOCAL_MODULE)
148 LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE_STEM)$(LOCAL_MODULE_SUFFIX)
150 LOCAL_BUILT_MODULE_STEM := $(strip $(LOCAL_BUILT_MODULE_STEM))
151 ifeq ($(LOCAL_BUILT_MODULE_STEM),)
152 LOCAL_BUILT_MODULE_STEM := $(LOCAL_INSTALLED_MODULE_STEM)
155 # OVERRIDE_BUILT_MODULE_PATH is only allowed to be used by the
156 # internal SHARED_LIBRARIES build files.
157 OVERRIDE_BUILT_MODULE_PATH := $(strip $(OVERRIDE_BUILT_MODULE_PATH))
158 ifdef OVERRIDE_BUILT_MODULE_PATH
159 ifneq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
160 $(error $(LOCAL_PATH): Illegal use of OVERRIDE_BUILT_MODULE_PATH)
162 built_module_path := $(OVERRIDE_BUILT_MODULE_PATH)
164 built_module_path := $(intermediates)
166 LOCAL_BUILT_MODULE := $(built_module_path)/$(LOCAL_BUILT_MODULE_STEM)
169 ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
170 LOCAL_INSTALLED_MODULE := $(LOCAL_MODULE_PATH)/$(LOCAL_INSTALLED_MODULE_STEM)
173 # Assemble the list of targets to create PRIVATE_ variables for.
174 LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE)
177 ###########################################################
178 ## AIDL: Compile .aidl files to .java
179 ###########################################################
181 aidl_sources := $(filter %.aidl,$(LOCAL_SRC_FILES))
183 ifneq ($(strip $(aidl_sources)),)
185 aidl_java_sources := $(patsubst %.aidl,%.java,$(addprefix $(intermediates.COMMON)/src/, $(aidl_sources)))
186 aidl_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(aidl_sources))
188 ifeq (,$(TARGET_BUILD_APPS))
189 LOCAL_AIDL_INCLUDES += $(FRAMEWORKS_BASE_JAVA_SRC_DIRS)
191 aidl_preprocess_import :=
192 LOCAL_SDK_VERSION:=$(strip $(LOCAL_SDK_VERSION))
193 ifdef LOCAL_SDK_VERSION
194 ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current)
195 # LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS
196 aidl_preprocess_import := $(TARGET_OUT_COMMON_INTERMEDIATES)/framework.aidl
198 aidl_preprocess_import := $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_VERSION)/framework.aidl
200 endif # LOCAL_SDK_VERSION
201 $(aidl_java_sources): PRIVATE_AIDL_FLAGS := -b $(addprefix -p,$(aidl_preprocess_import)) -I$(LOCAL_PATH) -I$(LOCAL_PATH)/src $(addprefix -I,$(LOCAL_AIDL_INCLUDES))
203 $(aidl_java_sources): $(intermediates.COMMON)/src/%.java: $(TOPDIR)$(LOCAL_PATH)/%.aidl $(LOCAL_ADDITIONAL_DEPENDENCIES) $(AIDL) $(aidl_preprocess_import)
204 $(transform-aidl-to-java)
205 -include $(aidl_java_sources:%.java=%.P)
211 ###########################################################
212 ## logtags: Add .logtags files to global list, emit java source
213 ###########################################################
215 logtags_sources := $(filter %.logtags,$(LOCAL_SRC_FILES))
217 ifneq ($(strip $(logtags_sources)),)
219 event_log_tags := $(addprefix $(LOCAL_PATH)/,$(logtags_sources))
221 # Emit a java source file with constants for the tags, if
222 # LOCAL_MODULE_CLASS is "APPS" or "JAVA_LIBRARIES".
223 ifneq ($(strip $(filter $(LOCAL_MODULE_CLASS),APPS JAVA_LIBRARIES)),)
225 logtags_java_sources := $(patsubst %.logtags,%.java,$(addprefix $(intermediates.COMMON)/src/, $(logtags_sources)))
226 logtags_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(logtags_sources))
228 $(logtags_java_sources): $(intermediates.COMMON)/src/%.java: $(TOPDIR)$(LOCAL_PATH)/%.logtags $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
229 $(transform-logtags-to-java)
234 logtags_java_sources :=
238 ###########################################################
239 ## .proto files: Compile proto files to .java
240 ###########################################################
241 proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES))
242 # Because names of the .java files compiled from .proto files are unknown until the
243 # .proto files are compiled, we use a timestamp file as depedency.
244 proto_java_sources_file_stamp :=
245 ifneq ($(proto_sources),)
246 proto_sources_fullpath := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(proto_sources))
247 # By putting the generated java files into $(LOCAL_INTERMEDIATE_SOURCE_DIR), they will be
248 # automatically found by the java compiling function transform-java-to-classes.jar.
249 ifneq ($(LOCAL_INTERMEDIATE_SOURCE_DIR),)
250 proto_java_intemediate_dir := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/proto
252 # LOCAL_INTERMEDIATE_SOURCE_DIR may be not defined in non-java modules.
253 proto_java_intemediate_dir := $(intermediates)/proto
255 proto_java_sources_file_stamp := $(proto_java_intemediate_dir)/Proto.stamp
256 proto_java_sources_dir := $(proto_java_intemediate_dir)/src
258 $(proto_java_sources_file_stamp): PRIVATE_PROTO_INCLUDES := $(TOP)
259 $(proto_java_sources_file_stamp): PRIVATE_PROTO_SRC_FILES := $(proto_sources_fullpath)
260 $(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_DIR := $(proto_java_sources_dir)
261 ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro)
262 $(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javamicro_out
264 ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nano)
265 $(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javanano_out
267 $(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --java_out
270 $(proto_java_sources_file_stamp): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS)
271 $(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_PARAMS := $(LOCAL_PROTO_JAVA_OUTPUT_PARAMS)
272 $(proto_java_sources_file_stamp) : $(proto_sources_fullpath) $(PROTOC)
273 $(call transform-proto-to-java)
275 #TODO: protoc should output the dependencies introduced by imports.
277 LOCAL_INTERMEDIATE_TARGETS += $(proto_java_sources_file_stamp)
278 endif # proto_sources
281 ###########################################################
282 ## Java: Compile .java files to .class
283 ###########################################################
284 #TODO: pull this into java.make once host and target are combined
286 java_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) $(aidl_java_sources) $(logtags_java_sources) \
287 $(filter %.java,$(LOCAL_GENERATED_SOURCES))
288 all_java_sources := $(java_sources) $(addprefix $($(my_prefix)OUT_COMMON_INTERMEDIATES)/, $(filter %.java,$(LOCAL_INTERMEDIATE_SOURCES)))
290 ## Java resources #########################################
292 # Look for resource files in any specified directories.
293 # Non-java and non-doc files will be picked up as resources
294 # and included in the output jar file.
295 java_resource_file_groups :=
297 LOCAL_JAVA_RESOURCE_DIRS := $(strip $(LOCAL_JAVA_RESOURCE_DIRS))
298 ifneq ($(LOCAL_JAVA_RESOURCE_DIRS),)
299 # This makes a list of words like
300 # <dir1>::<file1>:<file2> <dir2>::<file1> <dir3>:
301 # where each of the files is relative to the directory it's grouped with.
302 # Directories that don't contain any resource files will result in groups
303 # that end with a colon, and they are stripped out in the next step.
304 java_resource_file_groups += \
305 $(foreach dir,$(LOCAL_JAVA_RESOURCE_DIRS), \
306 $(subst $(space),:,$(strip \
307 $(TOP_DIR)$(LOCAL_PATH)/$(dir): \
308 $(patsubst ./%,%,$(shell cd $(TOP_DIR)$(LOCAL_PATH)/$(dir) && \
310 -type d -a -name ".svn" -prune -o \
312 -a \! -name "*.java" \
313 -a \! -name "package.html" \
314 -a \! -name "overview.html" \
315 -a \! -name ".*.swp" \
316 -a \! -name ".DS_Store" \
322 java_resource_file_groups := $(filter-out %:,$(java_resource_file_groups))
323 endif # LOCAL_JAVA_RESOURCE_DIRS
325 LOCAL_JAVA_RESOURCE_FILES := $(strip $(LOCAL_JAVA_RESOURCE_FILES))
326 ifneq ($(LOCAL_JAVA_RESOURCE_FILES),)
327 java_resource_file_groups += \
328 $(foreach f,$(LOCAL_JAVA_RESOURCE_FILES), \
329 $(patsubst %/,%,$(dir $(f)))::$(notdir $(f)) \
331 endif # LOCAL_JAVA_RESOURCE_FILES
333 ifdef java_resource_file_groups
334 # The full paths to all resources, used for dependencies.
335 java_resource_sources := \
336 $(foreach group,$(java_resource_file_groups), \
337 $(addprefix $(word 1,$(subst :,$(space),$(group)))/, \
338 $(wordlist 2,9999,$(subst :,$(space),$(group))) \
341 # The arguments to jar that will include these files in a jar file.
342 # Quote the file name to handle special characters (such as #) correctly.
344 $(foreach group,$(java_resource_file_groups), \
345 $(addprefix -C "$(word 1,$(subst :,$(space),$(group)))" , \
346 $(foreach w, $(wordlist 2,9999,$(subst :,$(space),$(group))), "$(w)" ) \
349 java_resource_file_groups :=
351 java_resource_sources :=
353 endif # java_resource_file_groups
355 ## PRIVATE java vars ######################################
356 # LOCAL_SOURCE_FILES_ALL_GENERATED is set only if the module does not have static source files,
357 # but generated source files in its LOCAL_INTERMEDIATE_SOURCE_DIR.
358 # You have to set up the dependency in some other way.
359 need_compile_java := $(strip $(all_java_sources)$(all_res_assets))$(LOCAL_STATIC_JAVA_LIBRARIES)$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED))
360 ifdef need_compile_java
362 full_static_java_libs := \
363 $(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES), \
364 $(call intermediates-dir-for, \
365 JAVA_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),COMMON)/javalib.jar)
367 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_INSTALL_DIR := $(dir $(LOCAL_INSTALLED_MODULE))
368 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates)/classes
369 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates)/src
370 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAVA_SOURCES := $(all_java_sources)
371 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAVA_OBJECTS := $(patsubst %.java,%.class,$(LOCAL_SRC_FILES))
372 ifeq ($(my_prefix),TARGET_)
373 ifeq ($(LOCAL_SDK_VERSION),)
374 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,core)
376 ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current)
377 # LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS.
378 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,android_stubs_current)
380 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,sdk_v$(LOCAL_SDK_VERSION))
382 endif # LOCAL_SDK_VERSION
384 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR)
385 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args)
386 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASSET_DIR := $(LOCAL_ASSET_DIR)
387 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_STATIC_JAVA_LIBRARIES := $(full_static_java_libs)
389 # full_java_libs: The list of files that should be used as the classpath.
390 # Using this list as a dependency list WILL NOT WORK.
391 # full_java_lib_deps: Should be specified as a prerequisite of this module
392 # to guarantee that the files in full_java_libs will
394 ifdef LOCAL_IS_HOST_MODULE
395 ifeq ($(LOCAL_BUILD_HOST_DEX),true)
396 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,core-hostdex,$(LOCAL_IS_HOST_MODULE))
398 full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
399 full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
401 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH :=
403 full_shared_java_libs := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/,\
404 $(addsuffix $(COMMON_JAVA_PACKAGE_SUFFIX),$(LOCAL_JAVA_LIBRARIES)))
405 full_java_lib_deps := $(full_shared_java_libs)
406 endif # LOCAL_BUILD_HOST_DEX
408 full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
409 full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
410 endif # !LOCAL_IS_HOST_MODULE
411 full_java_libs := $(full_shared_java_libs) $(full_static_java_libs) $(LOCAL_CLASSPATH)
412 full_java_lib_deps += $(full_static_java_libs) $(LOCAL_CLASSPATH)
414 # This is set by packages that are linking to other packages that export
415 # shared libraries, allowing them to make use of the code in the linked apk.
416 LOCAL_APK_LIBRARIES := $(strip $(LOCAL_APK_LIBRARIES))
417 ifdef LOCAL_APK_LIBRARIES
418 link_apk_libraries := \
419 $(foreach lib,$(LOCAL_APK_LIBRARIES), \
420 $(call intermediates-dir-for, \
421 APPS,$(lib),,COMMON)/classes.jar)
423 # link against the jar with full original names (before proguard processing).
424 full_shared_java_libs += $(link_apk_libraries)
425 full_java_libs += $(link_apk_libraries)
426 full_java_lib_deps += $(link_apk_libraries)
429 # This is set by packages that contain instrumentation, allowing them to
430 # link against the package they are instrumenting. Currently only one such
431 # package is allowed.
432 LOCAL_INSTRUMENTATION_FOR := $(strip $(LOCAL_INSTRUMENTATION_FOR))
433 ifdef LOCAL_INSTRUMENTATION_FOR
434 ifneq ($(words $(LOCAL_INSTRUMENTATION_FOR)),1)
436 $(LOCAL_PATH): Multiple LOCAL_INSTRUMENTATION_FOR members defined)
439 link_instr_intermediates_dir.COMMON := $(call intermediates-dir-for, \
440 APPS,$(LOCAL_INSTRUMENTATION_FOR),,COMMON)
441 # link against the jar with full original names (before proguard processing).
442 link_instr_classes_jar := $(link_instr_intermediates_dir.COMMON)/classes.jar
443 full_java_libs += $(link_instr_classes_jar)
444 full_java_lib_deps += $(link_instr_classes_jar)
448 ifneq ($(strip $(LOCAL_JAR_MANIFEST)),)
449 jar_manifest_file := $(LOCAL_PATH)/$(LOCAL_JAR_MANIFEST)
450 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST := $(jar_manifest_file)
452 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST :=
455 endif # need_compile_java
458 ###########################################################
459 ## make clean- targets
460 ###########################################################
461 cleantarget := clean-$(LOCAL_MODULE)
462 $(cleantarget) : PRIVATE_MODULE := $(LOCAL_MODULE)
463 $(cleantarget) : PRIVATE_CLEAN_FILES := \
464 $(LOCAL_BUILT_MODULE) \
465 $(LOCAL_INSTALLED_MODULE) \
468 @echo "Clean: $(PRIVATE_MODULE)"
469 $(hide) rm -rf $(PRIVATE_CLEAN_FILES)
471 ###########################################################
472 ## Common definitions for module.
473 ###########################################################
475 # aapt doesn't accept multiple --extra-packages flags.
476 # We have to collapse them into a single --extra-packages flag here.
477 LOCAL_AAPT_FLAGS := $(strip $(LOCAL_AAPT_FLAGS))
478 ifdef LOCAL_AAPT_FLAGS
479 ifeq ($(filter 0 1,$(words $(filter --extra-packages,$(LOCAL_AAPT_FLAGS)))),)
480 aapt_flags := $(subst --extra-packages$(space),--extra-packages@,$(LOCAL_AAPT_FLAGS))
481 aapt_flags_extra_packages := $(patsubst --extra-packages@%,%,$(filter --extra-packages@%,$(aapt_flags)))
482 aapt_flags_extra_packages := $(sort $(subst :,$(space),$(aapt_flags_extra_packages)))
483 LOCAL_AAPT_FLAGS := $(filter-out --extra-packages@%,$(aapt_flags)) \
484 --extra-packages $(subst $(space),:,$(aapt_flags_extra_packages))
485 aapt_flags_extra_packages :=
490 # Propagate local configuration options to this target.
491 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PATH:=$(LOCAL_PATH)
492 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_AAPT_FLAGS:= $(LOCAL_AAPT_FLAGS)
493 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_JAVA_LIBRARIES:= $(LOCAL_JAVA_LIBRARIES)
494 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MANIFEST_PACKAGE_NAME:= $(LOCAL_MANIFEST_PACKAGE_NAME)
495 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MANIFEST_INSTRUMENTATION_FOR:= $(LOCAL_MANIFEST_INSTRUMENTATION_FOR)
497 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_ALL_JAVA_LIBRARIES:= $(full_java_libs)
498 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_IS_HOST_MODULE := $(LOCAL_IS_HOST_MODULE)
499 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_HOST:= $(my_host)
501 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_INTERMEDIATES_DIR:= $(intermediates)
503 # Tell the module and all of its sub-modules who it is.
504 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MODULE:= $(LOCAL_MODULE)
506 # Provide a short-hand for building this module.
507 # We name both BUILT and INSTALLED in case
508 # LOCAL_UNINSTALLABLE_MODULE is set.
509 .PHONY: $(LOCAL_MODULE)
510 $(LOCAL_MODULE): $(LOCAL_BUILT_MODULE) $(LOCAL_INSTALLED_MODULE)
512 ###########################################################
513 ## Module installation rule
514 ###########################################################
516 # Some hosts do not have ACP; override the LOCAL version if that's the case.
517 ifneq ($(strip $(HOST_ACP_UNAVAILABLE)),)
518 LOCAL_ACP_UNAVAILABLE := $(strip $(HOST_ACP_UNAVAILABLE))
521 ifndef LOCAL_UNINSTALLABLE_MODULE
522 # Define a copy rule to install the module.
523 # acp and libraries that it uses can't use acp for
524 # installation; hence, LOCAL_ACP_UNAVAILABLE.
525 $(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD)
526 ifneq ($(LOCAL_ACP_UNAVAILABLE),true)
527 $(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE) | $(ACP)
529 $(copy-file-to-new-target)
530 $(PRIVATE_POST_INSTALL_CMD)
532 $(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE)
534 $(copy-file-to-target-with-cp)
537 ifdef LOCAL_DEX_PREOPT
538 installed_odex := $(basename $(LOCAL_INSTALLED_MODULE)).odex
539 built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex
540 $(installed_odex) : $(built_odex) $(LOCAL_BUILT_MODULE) | $(ACP)
542 $(copy-file-to-target)
544 $(LOCAL_INSTALLED_MODULE) : $(installed_odex)
546 endif # !LOCAL_UNINSTALLABLE_MODULE
549 ###########################################################
551 ###########################################################
553 ifdef java_alternative_checked_module
554 LOCAL_CHECKED_MODULE := $(java_alternative_checked_module)
557 # If nobody has defined a more specific module for the
558 # checked modules, use LOCAL_BUILT_MODULE.
559 ifndef LOCAL_CHECKED_MODULE
560 LOCAL_CHECKED_MODULE := $(LOCAL_BUILT_MODULE)
563 # If they request that this module not be checked, then don't.
564 # PLEASE DON'T SET THIS. ANY PLACES THAT SET THIS WITHOUT
565 # GOOD REASON WILL HAVE IT REMOVED.
566 ifdef LOCAL_DONT_CHECK_MODULE
567 LOCAL_CHECKED_MODULE :=
570 ###########################################################
571 ## Register with ALL_MODULES
572 ###########################################################
574 ALL_MODULES += $(LOCAL_MODULE)
576 # Don't use += on subvars, or else they'll end up being
577 # recursively expanded.
578 ALL_MODULES.$(LOCAL_MODULE).CLASS := \
579 $(ALL_MODULES.$(LOCAL_MODULE).CLASS) $(LOCAL_MODULE_CLASS)
580 ALL_MODULES.$(LOCAL_MODULE).PATH := \
581 $(ALL_MODULES.$(LOCAL_MODULE).PATH) $(LOCAL_PATH)
582 ALL_MODULES.$(LOCAL_MODULE).TAGS := \
583 $(ALL_MODULES.$(LOCAL_MODULE).TAGS) $(LOCAL_MODULE_TAGS)
584 ALL_MODULES.$(LOCAL_MODULE).CHECKED := \
585 $(ALL_MODULES.$(LOCAL_MODULE).CHECKED) $(LOCAL_CHECKED_MODULE)
586 ALL_MODULES.$(LOCAL_MODULE).BUILT := \
587 $(ALL_MODULES.$(LOCAL_MODULE).BUILT) $(LOCAL_BUILT_MODULE)
588 ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
589 $(strip $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(LOCAL_INSTALLED_MODULE))
590 ALL_MODULES.$(LOCAL_MODULE).REQUIRED := \
591 $(ALL_MODULES.$(LOCAL_MODULE).REQUIRED) $(LOCAL_REQUIRED_MODULES)
592 ALL_MODULES.$(LOCAL_MODULE).EVENT_LOG_TAGS := \
593 $(ALL_MODULES.$(LOCAL_MODULE).EVENT_LOG_TAGS) $(event_log_tags)
594 ALL_MODULES.$(LOCAL_MODULE).INTERMEDIATE_SOURCE_DIR := \
595 $(ALL_MODULES.$(LOCAL_MODULE).INTERMEDIATE_SOURCE_DIR) $(LOCAL_INTERMEDIATE_SOURCE_DIR)
596 ALL_MODULES.$(LOCAL_MODULE).MAKEFILE := \
597 $(ALL_MODULES.$(LOCAL_MODULE).MAKEFILE) $(LOCAL_MODULE_MAKEFILE)
598 ifdef LOCAL_MODULE_OWNER
599 ALL_MODULES.$(LOCAL_MODULE).OWNER := \
600 $(sort $(ALL_MODULES.$(LOCAL_MODULE).OWNER) $(LOCAL_MODULE_OWNER))
603 INSTALLABLE_FILES.$(LOCAL_INSTALLED_MODULE).MODULE := $(LOCAL_MODULE)
605 ###########################################################
606 ## Take care of LOCAL_MODULE_TAGS
607 ###########################################################
609 # Keep track of all the tags we've seen.
610 ALL_MODULE_TAGS := $(sort $(ALL_MODULE_TAGS) $(LOCAL_MODULE_TAGS))
612 # Add this module to the tag list of each specified tag.
613 # Don't use "+=". If the variable hasn't been set with ":=",
614 # it will default to recursive expansion.
615 $(foreach tag,$(LOCAL_MODULE_TAGS),\
616 $(eval ALL_MODULE_TAGS.$(tag) := \
617 $(ALL_MODULE_TAGS.$(tag)) \
618 $(LOCAL_INSTALLED_MODULE)))
620 # Add this module name to the tag list of each specified tag.
621 $(foreach tag,$(LOCAL_MODULE_TAGS),\
622 $(eval ALL_MODULE_NAME_TAGS.$(tag) += $(LOCAL_MODULE)))
624 ###########################################################
625 ## umbrella targets used to verify builds
626 ###########################################################
628 ifneq (,$(filter EXECUTABLES SHARED_LIBRARIES STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS)))
631 ifneq (,$(filter JAVA_LIBRARIES APPS,$(LOCAL_MODULE_CLASS)))
635 ifdef LOCAL_IS_HOST_MODULE
642 $(j_or_n) $(h_or_t) $(j_or_n)-$(h_or_t) : $(LOCAL_CHECKED_MODULE)
643 ifneq (,$(filter $(LOCAL_MODULE_TAGS),tests))
644 $(j_or_n)-$(h_or_t)-tests $(j_or_n)-tests $(h_or_t)-tests : $(LOCAL_CHECKED_MODULE)
648 ###########################################################
650 ###########################################################
652 include $(BUILD_NOTICE_FILE)