base_rules.mk revision 3d48122b18398e16af61fd4bf4796991a09d54c3
1#
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_UNINSTALLABLE_MODULE := $(strip $(LOCAL_UNINSTALLABLE_MODULE))
59LOCAL_MODULE_TAGS := $(sort $(LOCAL_MODULE_TAGS))
60ifeq (,$(LOCAL_MODULE_TAGS))
61  LOCAL_MODULE_TAGS := optional
62endif
63
64# User tags are not allowed anymore.  Fail early because it will not be installed
65# like it used to be.
66ifneq ($(filter $(LOCAL_MODULE_TAGS),user),)
67  $(warning *** Module name: $(LOCAL_MODULE))
68  $(warning *** Makefile location: $(LOCAL_MODULE_MAKEFILE))
69  $(warning * )
70  $(warning * Module is attempting to use the 'user' tag.  This)
71  $(warning * used to cause the module to be installed automatically.)
72  $(warning * Now, the module must be listed in the PRODUCT_PACKAGES)
73  $(warning * section of a product makefile to have it installed.)
74  $(warning * )
75  $(error user tag detected on module.)
76endif
77
78# Only the tags mentioned in this test are expected to be set by module
79# makefiles. Anything else is either a typo or a source of unexpected
80# behaviors.
81ifneq ($(filter-out debug eng tests optional samples shell_ash shell_mksh,$(LOCAL_MODULE_TAGS)),)
82$(warning unusual tags $(LOCAL_MODULE_TAGS) on $(LOCAL_MODULE) at $(LOCAL_PATH))
83endif
84
85# Add implicit tags.
86#
87# If the local directory or one of its parents contains a MODULE_LICENSE_GPL
88# file, tag the module as "gnu".  Search for "*_GPL*" and "*_MPL*" so that we can also
89# find files like MODULE_LICENSE_GPL_AND_AFL but exclude files like
90# MODULE_LICENSE_LGPL.
91#
92gpl_license_file := $(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*_GPL* MODULE_LICENSE*_MPL*)
93ifneq ($(gpl_license_file),)
94  LOCAL_MODULE_TAGS += gnu
95  ALL_GPL_MODULE_LICENSE_FILES := $(sort $(ALL_GPL_MODULE_LICENSE_FILES) $(gpl_license_file))
96endif
97
98LOCAL_MODULE_CLASS := $(strip $(LOCAL_MODULE_CLASS))
99ifneq ($(words $(LOCAL_MODULE_CLASS)),1)
100  $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS must contain exactly one word, not "$(LOCAL_MODULE_CLASS)")
101endif
102
103ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
104ifdef LOCAL_IS_HOST_MODULE
105  partition_tag :=
106else
107ifeq (true,$(LOCAL_PROPRIETARY_MODULE))
108  partition_tag := _VENDOR
109else
110  # The definition of should-install-to-system will be different depending
111  # on which goal (e.g., sdk or just droid) is being built.
112  partition_tag := $(if $(call should-install-to-system,$(LOCAL_MODULE_TAGS)),,_DATA)
113endif
114endif
115
116LOCAL_MODULE_PATH := $(strip $(LOCAL_MODULE_PATH))
117ifeq ($(LOCAL_MODULE_PATH),)
118  LOCAL_MODULE_PATH := $($(my_prefix)OUT$(partition_tag)_$(LOCAL_MODULE_CLASS))
119  ifeq ($(strip $(LOCAL_MODULE_PATH)),)
120    $(error $(LOCAL_PATH): unhandled LOCAL_MODULE_CLASS "$(LOCAL_MODULE_CLASS)")
121  endif
122endif
123endif # not LOCAL_UNINSTALLABLE_MODULE
124
125ifneq ($(strip $(LOCAL_BUILT_MODULE)$(LOCAL_INSTALLED_MODULE)),)
126  $(error $(LOCAL_PATH): LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE must not be defined by component makefiles)
127endif
128
129# Make sure that this IS_HOST/CLASS/MODULE combination is unique.
130module_id := MODULE.$(if \
131    $(LOCAL_IS_HOST_MODULE),HOST,TARGET).$(LOCAL_MODULE_CLASS).$(LOCAL_MODULE)
132ifdef $(module_id)
133$(error $(LOCAL_PATH): $(module_id) already defined by $($(module_id)))
134endif
135$(module_id) := $(LOCAL_PATH)
136
137intermediates := $(call local-intermediates-dir)
138intermediates.COMMON := $(call local-intermediates-dir,COMMON)
139
140###########################################################
141# Pick a name for the intermediate and final targets
142###########################################################
143LOCAL_MODULE_STEM := $(strip $(LOCAL_MODULE_STEM))
144ifeq ($(LOCAL_MODULE_STEM),)
145  LOCAL_MODULE_STEM := $(LOCAL_MODULE)
146endif
147LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE_STEM)$(LOCAL_MODULE_SUFFIX)
148
149LOCAL_BUILT_MODULE_STEM := $(strip $(LOCAL_BUILT_MODULE_STEM))
150ifeq ($(LOCAL_BUILT_MODULE_STEM),)
151  LOCAL_BUILT_MODULE_STEM := $(LOCAL_INSTALLED_MODULE_STEM)
152endif
153
154# OVERRIDE_BUILT_MODULE_PATH is only allowed to be used by the
155# internal SHARED_LIBRARIES build files.
156OVERRIDE_BUILT_MODULE_PATH := $(strip $(OVERRIDE_BUILT_MODULE_PATH))
157ifdef OVERRIDE_BUILT_MODULE_PATH
158  ifneq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
159    $(error $(LOCAL_PATH): Illegal use of OVERRIDE_BUILT_MODULE_PATH)
160  endif
161  built_module_path := $(OVERRIDE_BUILT_MODULE_PATH)
162else
163  built_module_path := $(intermediates)
164endif
165LOCAL_BUILT_MODULE := $(built_module_path)/$(LOCAL_BUILT_MODULE_STEM)
166built_module_path :=
167
168ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
169  LOCAL_INSTALLED_MODULE := $(LOCAL_MODULE_PATH)/$(LOCAL_INSTALLED_MODULE_STEM)
170endif
171
172# Assemble the list of targets to create PRIVATE_ variables for.
173LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE)
174
175
176###########################################################
177## AIDL: Compile .aidl files to .java
178###########################################################
179
180aidl_sources := $(filter %.aidl,$(LOCAL_SRC_FILES))
181
182ifneq ($(strip $(aidl_sources)),)
183
184aidl_java_sources := $(patsubst %.aidl,%.java,$(addprefix $(intermediates.COMMON)/src/, $(aidl_sources)))
185aidl_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(aidl_sources))
186
187ifeq (,$(TARGET_BUILD_APPS))
188LOCAL_AIDL_INCLUDES += $(FRAMEWORKS_BASE_JAVA_SRC_DIRS)
189endif
190aidl_preprocess_import :=
191LOCAL_SDK_VERSION:=$(strip $(LOCAL_SDK_VERSION))
192ifdef LOCAL_SDK_VERSION
193ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current)
194  # LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS
195  aidl_preprocess_import := $(TARGET_OUT_COMMON_INTERMEDIATES)/framework.aidl
196else
197  aidl_preprocess_import := $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_VERSION)/framework.aidl
198endif # !current
199endif # LOCAL_SDK_VERSION
200$(aidl_java_sources): PRIVATE_AIDL_FLAGS := -b $(addprefix -p,$(aidl_preprocess_import)) -I$(LOCAL_PATH) -I$(LOCAL_PATH)/src $(addprefix -I,$(LOCAL_AIDL_INCLUDES))
201
202$(aidl_java_sources): $(intermediates.COMMON)/src/%.java: $(TOPDIR)$(LOCAL_PATH)/%.aidl $(LOCAL_ADDITIONAL_DEPENDENCIES) $(AIDL) $(aidl_preprocess_import)
203	$(transform-aidl-to-java)
204-include $(aidl_java_sources:%.java=%.P)
205
206else
207aidl_java_sources :=
208endif
209
210###########################################################
211## logtags: Add .logtags files to global list, emit java source
212###########################################################
213
214logtags_sources := $(filter %.logtags,$(LOCAL_SRC_FILES))
215
216ifneq ($(strip $(logtags_sources)),)
217
218event_log_tags := $(addprefix $(LOCAL_PATH)/,$(logtags_sources))
219
220# Emit a java source file with constants for the tags, if
221# LOCAL_MODULE_CLASS is "APPS" or "JAVA_LIBRARIES".
222ifneq ($(strip $(filter $(LOCAL_MODULE_CLASS),APPS JAVA_LIBRARIES)),)
223
224logtags_java_sources := $(patsubst %.logtags,%.java,$(addprefix $(intermediates.COMMON)/src/, $(logtags_sources)))
225logtags_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(logtags_sources))
226
227$(logtags_java_sources): $(intermediates.COMMON)/src/%.java: $(TOPDIR)$(LOCAL_PATH)/%.logtags $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
228	$(transform-logtags-to-java)
229
230endif
231
232else
233logtags_java_sources :=
234event_log_tags :=
235endif
236
237###########################################################
238## .proto files: Compile proto files to .java
239###########################################################
240proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES))
241# Because names of the .java files compiled from .proto files are unknown until the
242# .proto files are compiled, we use a timestamp file as depedency.
243proto_java_sources_file_stamp :=
244ifneq ($(proto_sources),)
245proto_sources_fullpath := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(proto_sources))
246# By putting the generated java files into $(LOCAL_INTERMEDIATE_SOURCE_DIR), they will be
247# automatically found by the java compiling function transform-java-to-classes.jar.
248ifneq ($(LOCAL_INTERMEDIATE_SOURCE_DIR),)
249proto_java_intemediate_dir := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/proto
250else
251# LOCAL_INTERMEDIATE_SOURCE_DIR may be not defined in non-java modules.
252proto_java_intemediate_dir := $(intermediates)/proto
253endif
254proto_java_sources_file_stamp := $(proto_java_intemediate_dir)/Proto.stamp
255proto_java_sources_dir := $(proto_java_intemediate_dir)/src
256
257$(proto_java_sources_file_stamp): PRIVATE_PROTO_INCLUDES := $(TOP)
258$(proto_java_sources_file_stamp): PRIVATE_PROTO_SRC_FILES := $(proto_sources_fullpath)
259$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_DIR := $(proto_java_sources_dir)
260ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro)
261$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javamicro_out
262else
263$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --java_out
264endif
265$(proto_java_sources_file_stamp): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS)
266$(proto_java_sources_file_stamp) : $(proto_sources_fullpath) $(PROTOC)
267	$(call transform-proto-to-java)
268
269#TODO: protoc should output the dependencies introduced by imports.
270
271LOCAL_INTERMEDIATE_TARGETS += $(proto_java_sources_file_stamp)
272endif # proto_sources
273
274
275###########################################################
276## Java: Compile .java files to .class
277###########################################################
278#TODO: pull this into java.make once host and target are combined
279
280java_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) $(aidl_java_sources) $(logtags_java_sources) \
281                $(filter %.java,$(LOCAL_GENERATED_SOURCES))
282all_java_sources := $(java_sources) $(addprefix $($(my_prefix)OUT_COMMON_INTERMEDIATES)/, $(filter %.java,$(LOCAL_INTERMEDIATE_SOURCES)))
283
284## Java resources #########################################
285
286# Look for resource files in any specified directories.
287# Non-java and non-doc files will be picked up as resources
288# and included in the output jar file.
289java_resource_file_groups :=
290
291LOCAL_JAVA_RESOURCE_DIRS := $(strip $(LOCAL_JAVA_RESOURCE_DIRS))
292ifneq ($(LOCAL_JAVA_RESOURCE_DIRS),)
293  # This makes a list of words like
294  #     <dir1>::<file1>:<file2> <dir2>::<file1> <dir3>:
295  # where each of the files is relative to the directory it's grouped with.
296  # Directories that don't contain any resource files will result in groups
297  # that end with a colon, and they are stripped out in the next step.
298  java_resource_file_groups += \
299    $(foreach dir,$(LOCAL_JAVA_RESOURCE_DIRS), \
300	$(subst $(space),:,$(strip \
301		$(TOP_DIR)$(LOCAL_PATH)/$(dir): \
302	    $(patsubst ./%,%,$(shell cd $(TOP_DIR)$(LOCAL_PATH)/$(dir) && \
303		find . \
304		    -type d -a -name ".svn" -prune -o \
305		    -type f \
306			-a \! -name "*.java" \
307			-a \! -name "package.html" \
308			-a \! -name "overview.html" \
309			-a \! -name ".*.swp" \
310			-a \! -name ".DS_Store" \
311			-a \! -name "*~" \
312			-print \
313		    )) \
314	)) \
315    )
316  java_resource_file_groups := $(filter-out %:,$(java_resource_file_groups))
317endif # LOCAL_JAVA_RESOURCE_DIRS
318
319LOCAL_JAVA_RESOURCE_FILES := $(strip $(LOCAL_JAVA_RESOURCE_FILES))
320ifneq ($(LOCAL_JAVA_RESOURCE_FILES),)
321  java_resource_file_groups += \
322    $(foreach f,$(LOCAL_JAVA_RESOURCE_FILES), \
323	$(patsubst %/,%,$(dir $(f)))::$(notdir $(f)) \
324     )
325endif # LOCAL_JAVA_RESOURCE_FILES
326
327ifdef java_resource_file_groups
328  # The full paths to all resources, used for dependencies.
329  java_resource_sources := \
330    $(foreach group,$(java_resource_file_groups), \
331	$(addprefix $(word 1,$(subst :,$(space),$(group)))/, \
332	    $(wordlist 2,9999,$(subst :,$(space),$(group))) \
333	) \
334    )
335  # The arguments to jar that will include these files in a jar file.
336  # Quote the file name to handle special characters (such as #) correctly.
337  extra_jar_args := \
338    $(foreach group,$(java_resource_file_groups), \
339	$(addprefix -C "$(word 1,$(subst :,$(space),$(group)))" , \
340	    $(foreach w, $(wordlist 2,9999,$(subst :,$(space),$(group))), "$(w)" ) \
341	) \
342    )
343  java_resource_file_groups :=
344else
345  java_resource_sources :=
346  extra_jar_args :=
347endif # java_resource_file_groups
348
349## PRIVATE java vars ######################################
350
351ifneq ($(strip $(all_java_sources)$(all_res_assets))$(LOCAL_STATIC_JAVA_LIBRARIES),)
352
353full_static_java_libs := \
354    $(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES), \
355      $(call intermediates-dir-for, \
356        JAVA_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),COMMON)/javalib.jar)
357
358$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_INSTALL_DIR := $(dir $(LOCAL_INSTALLED_MODULE))
359$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates)/classes
360$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates)/src
361$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAVA_SOURCES := $(all_java_sources)
362$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAVA_OBJECTS := $(patsubst %.java,%.class,$(LOCAL_SRC_FILES))
363ifeq ($(my_prefix),TARGET_)
364ifeq ($(LOCAL_SDK_VERSION),)
365$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,core)
366else
367ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current)
368# LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS.
369$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,android_stubs_current)
370else
371$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,sdk_v$(LOCAL_SDK_VERSION))
372endif # current
373endif # LOCAL_SDK_VERSION
374endif # TARGET_
375$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR)
376$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args)
377$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASSET_DIR := $(LOCAL_ASSET_DIR)
378$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_STATIC_JAVA_LIBRARIES := $(full_static_java_libs)
379
380# full_java_libs: The list of files that should be used as the classpath.
381#                 Using this list as a dependency list WILL NOT WORK.
382# full_java_lib_deps: Should be specified as a prerequisite of this module
383#                 to guarantee that the files in full_java_libs will
384#                 be up-to-date.
385ifdef LOCAL_IS_HOST_MODULE
386ifeq ($(LOCAL_BUILD_HOST_DEX),true)
387$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,core-hostdex,$(LOCAL_IS_HOST_MODULE))
388
389full_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
390full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
391else
392$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH :=
393
394full_java_libs := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/,$(addsuffix $(COMMON_JAVA_PACKAGE_SUFFIX),$(LOCAL_JAVA_LIBRARIES)))
395full_java_lib_deps := $(full_java_libs)
396endif # LOCAL_BUILD_HOST_DEX
397else
398full_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
399full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
400endif # !LOCAL_IS_HOST_MODULE
401full_java_libs += $(full_static_java_libs) $(LOCAL_CLASSPATH)
402full_java_lib_deps += $(full_static_java_libs) $(LOCAL_CLASSPATH)
403
404# This is set by packages that contain instrumentation, allowing them to
405# link against the package they are instrumenting.  Currently only one such
406# package is allowed.
407LOCAL_INSTRUMENTATION_FOR := $(strip $(LOCAL_INSTRUMENTATION_FOR))
408ifdef LOCAL_INSTRUMENTATION_FOR
409  ifneq ($(words $(LOCAL_INSTRUMENTATION_FOR)),1)
410    $(error \
411        $(LOCAL_PATH): Multiple LOCAL_INSTRUMENTATION_FOR members defined)
412  endif
413
414  link_instr_intermediates_dir := $(call intermediates-dir-for, \
415      APPS,$(LOCAL_INSTRUMENTATION_FOR))
416  link_instr_intermediates_dir.COMMON := $(call intermediates-dir-for, \
417      APPS,$(LOCAL_INSTRUMENTATION_FOR),,COMMON)
418
419  # link against the jar with full original names (before proguard processing).
420  full_java_libs += $(link_instr_intermediates_dir.COMMON)/classes.jar
421  full_java_lib_deps += $(link_instr_intermediates_dir.COMMON)/classes.jar
422endif
423
424jar_manifest_file :=
425ifneq ($(strip $(LOCAL_JAR_MANIFEST)),)
426jar_manifest_file := $(LOCAL_PATH)/$(LOCAL_JAR_MANIFEST)
427$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST := $(jar_manifest_file)
428else
429$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST :=
430endif
431
432endif
433
434
435###########################################################
436## make clean- targets
437###########################################################
438cleantarget := clean-$(LOCAL_MODULE)
439$(cleantarget) : PRIVATE_MODULE := $(LOCAL_MODULE)
440$(cleantarget) : PRIVATE_CLEAN_FILES := \
441		$(PRIVATE_CLEAN_FILES) \
442		$(LOCAL_BUILT_MODULE) \
443		$(LOCAL_INSTALLED_MODULE) \
444		$(intermediates)
445$(cleantarget)::
446	@echo "Clean: $(PRIVATE_MODULE)"
447	$(hide) rm -rf $(PRIVATE_CLEAN_FILES)
448
449###########################################################
450## Common definitions for module.
451###########################################################
452
453# Propagate local configuration options to this target.
454$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PATH:=$(LOCAL_PATH)
455$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_POST_PROCESS_COMMAND:= $(LOCAL_POST_PROCESS_COMMAND)
456$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_AAPT_FLAGS:= $(LOCAL_AAPT_FLAGS)
457$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_JAVA_LIBRARIES:= $(LOCAL_JAVA_LIBRARIES)
458$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MANIFEST_PACKAGE_NAME:= $(LOCAL_MANIFEST_PACKAGE_NAME)
459$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MANIFEST_INSTRUMENTATION_FOR:= $(LOCAL_MANIFEST_INSTRUMENTATION_FOR)
460
461$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_ALL_JAVA_LIBRARIES:= $(full_java_libs)
462$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_IS_HOST_MODULE := $(LOCAL_IS_HOST_MODULE)
463$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_HOST:= $(my_host)
464
465$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_INTERMEDIATES_DIR:= $(intermediates)
466
467# Tell the module and all of its sub-modules who it is.
468$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MODULE:= $(LOCAL_MODULE)
469
470# Provide a short-hand for building this module.
471# We name both BUILT and INSTALLED in case
472# LOCAL_UNINSTALLABLE_MODULE is set.
473.PHONY: $(LOCAL_MODULE)
474$(LOCAL_MODULE): $(LOCAL_BUILT_MODULE) $(LOCAL_INSTALLED_MODULE)
475
476###########################################################
477## Module installation rule
478###########################################################
479
480# Some hosts do not have ACP; override the LOCAL version if that's the case.
481ifneq ($(strip $(HOST_ACP_UNAVAILABLE)),)
482  LOCAL_ACP_UNAVAILABLE := $(strip $(HOST_ACP_UNAVAILABLE))
483endif
484
485ifndef LOCAL_UNINSTALLABLE_MODULE
486  # Define a copy rule to install the module.
487  # acp and libraries that it uses can't use acp for
488  # installation;  hence, LOCAL_ACP_UNAVAILABLE.
489ifneq ($(LOCAL_ACP_UNAVAILABLE),true)
490$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE) | $(ACP)
491	@echo "Install: $@"
492	$(copy-file-to-new-target)
493else
494$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE)
495	@echo "Install: $@"
496	$(copy-file-to-target-with-cp)
497endif
498
499ifdef LOCAL_DEX_PREOPT
500installed_odex := $(basename $(LOCAL_INSTALLED_MODULE)).odex
501built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex
502$(installed_odex) : $(built_odex) | $(ACP)
503	@echo "Install: $@"
504	$(copy-file-to-target)
505
506$(LOCAL_INSTALLED_MODULE) : $(installed_odex)
507endif
508
509# All host modules that are not tagged with optional are automatically installed.
510# Save the installed files in ALL_HOST_INSTALLED_FILES.
511ifeq ($(LOCAL_IS_HOST_MODULE),true)
512  ifneq ($(filter optional,$(LOCAL_MODULE_TAGS)),optional)
513    ALL_HOST_INSTALLED_FILES += $(LOCAL_INSTALLED_MODULE)
514  endif
515  ifneq ($(filter debug eng tests, $(LOCAL_MODULE_TAGS)),)
516    $(error $(LOCAL_MODULE_MAKEFILE): Host module "$(LOCAL_MODULE)" has useless module tags: $(filter debug eng tests, $(LOCAL_MODULE_TAGS)). It will be installed anyway.)
517  endif
518endif
519
520endif # !LOCAL_UNINSTALLABLE_MODULE
521
522
523###########################################################
524## CHECK_BUILD goals
525###########################################################
526
527# If nobody has defined a more specific module for the
528# checked modules, use LOCAL_BUILT_MODULE.  This was old
529# behavior, so it should be a safe default.
530ifndef LOCAL_CHECKED_MODULE
531  ifndef LOCAL_SDK_VERSION
532    LOCAL_CHECKED_MODULE := $(LOCAL_BUILT_MODULE)
533  endif
534endif
535
536# If they request that this module not be checked, then don't.
537# PLEASE DON'T SET THIS.  ANY PLACES THAT SET THIS WITHOUT
538# GOOD REASON WILL HAVE IT REMOVED.
539ifdef LOCAL_DONT_CHECK_MODULE
540  LOCAL_CHECKED_MODULE :=
541endif
542
543###########################################################
544## Register with ALL_MODULES
545###########################################################
546
547ALL_MODULES += $(LOCAL_MODULE)
548
549# Don't use += on subvars, or else they'll end up being
550# recursively expanded.
551ALL_MODULES.$(LOCAL_MODULE).CLASS := \
552    $(ALL_MODULES.$(LOCAL_MODULE).CLASS) $(LOCAL_MODULE_CLASS)
553ALL_MODULES.$(LOCAL_MODULE).PATH := \
554    $(ALL_MODULES.$(LOCAL_MODULE).PATH) $(LOCAL_PATH)
555ALL_MODULES.$(LOCAL_MODULE).TAGS := \
556    $(ALL_MODULES.$(LOCAL_MODULE).TAGS) $(LOCAL_MODULE_TAGS)
557ALL_MODULES.$(LOCAL_MODULE).CHECKED := \
558    $(ALL_MODULES.$(LOCAL_MODULE).CHECKED) $(LOCAL_CHECKED_MODULE)
559ALL_MODULES.$(LOCAL_MODULE).BUILT := \
560    $(ALL_MODULES.$(LOCAL_MODULE).BUILT) $(LOCAL_BUILT_MODULE)
561ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
562    $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(LOCAL_INSTALLED_MODULE)
563ALL_MODULES.$(LOCAL_MODULE).REQUIRED := \
564    $(ALL_MODULES.$(LOCAL_MODULE).REQUIRED) $(LOCAL_REQUIRED_MODULES)
565ALL_MODULES.$(LOCAL_MODULE).EVENT_LOG_TAGS := \
566    $(ALL_MODULES.$(LOCAL_MODULE).EVENT_LOG_TAGS) $(event_log_tags)
567ALL_MODULES.$(LOCAL_MODULE).INTERMEDIATE_SOURCE_DIR := \
568    $(ALL_MODULES.$(LOCAL_MODULE).INTERMEDIATE_SOURCE_DIR) $(LOCAL_INTERMEDIATE_SOURCE_DIR)
569ALL_MODULES.$(LOCAL_MODULE).MAKEFILE := \
570    $(ALL_MODULES.$(LOCAL_MODULE).MAKEFILE) $(LOCAL_MODULE_MAKEFILE)
571ifdef LOCAL_MODULE_OWNER
572ALL_MODULES.$(LOCAL_MODULE).OWNER := \
573    $(strip $(ALL_MODULES.$(LOCAL_MODULE).OWNER) $(LOCAL_MODULE_OWNER))
574endif
575
576INSTALLABLE_FILES.$(LOCAL_INSTALLED_MODULE).MODULE := $(LOCAL_MODULE)
577
578###########################################################
579## Take care of LOCAL_MODULE_TAGS
580###########################################################
581
582# Keep track of all the tags we've seen.
583ALL_MODULE_TAGS := $(sort $(ALL_MODULE_TAGS) $(LOCAL_MODULE_TAGS))
584
585# Add this module to the tag list of each specified tag.
586# Don't use "+=". If the variable hasn't been set with ":=",
587# it will default to recursive expansion.
588$(foreach tag,$(LOCAL_MODULE_TAGS),\
589    $(eval ALL_MODULE_TAGS.$(tag) := \
590	    $(ALL_MODULE_TAGS.$(tag)) \
591	    $(LOCAL_INSTALLED_MODULE)))
592
593# Add this module name to the tag list of each specified tag.
594$(foreach tag,$(LOCAL_MODULE_TAGS),\
595    $(eval ALL_MODULE_NAME_TAGS.$(tag) += $(LOCAL_MODULE)))
596
597###########################################################
598## NOTICE files
599###########################################################
600
601include $(BUILD_SYSTEM)/notice_files.mk
602
603#:vi noexpandtab
604