Home | History | Annotate | Download | only in core
      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.
     19 ifdef base-rules-hook
     20 $(if $(base-rules-hook),)
     21 endif
     22 
     23 ###########################################################
     24 ## Common instructions for a generic module.
     25 ###########################################################
     26 
     27 LOCAL_MODULE := $(strip $(LOCAL_MODULE))
     28 ifeq ($(LOCAL_MODULE),)
     29   $(error $(LOCAL_PATH): LOCAL_MODULE is not defined)
     30 endif
     31 
     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)")
     36   endif
     37   my_prefix := HOST_
     38   my_host := host-
     39 else
     40   my_prefix := TARGET_
     41   my_host :=
     42 endif
     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 #$(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 
     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
     59 endif
     60 
     61 # User tags are not allowed anymore.  Fail early because it will not be installed
     62 # like it used to be.
     63 ifneq ($(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.)
     73 endif
     74 
     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
     77 # behaviors.
     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))
     80 endif
     81 
     82 # Add implicit tags.
     83 #
     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.
     88 #
     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))
     93 endif
     94 
     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)")
     98 endif
     99 
    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
    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))
    120   ifeq ($(strip $(LOCAL_MODULE_PATH)),)
    121     $(error $(LOCAL_PATH): unhandled install path "$(install_path_var)")
    122   endif
    123 endif
    124 endif # not LOCAL_UNINSTALLABLE_MODULE
    125 
    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)
    128 endif
    129 
    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)
    133 ifdef $(module_id)
    134 $(error $(LOCAL_PATH): $(module_id) already defined by $($(module_id)))
    135 endif
    136 $(module_id) := $(LOCAL_PATH)
    137 
    138 intermediates := $(call local-intermediates-dir)
    139 intermediates.COMMON := $(call local-intermediates-dir,COMMON)
    140 
    141 ###########################################################
    142 # Pick a name for the intermediate and final targets
    143 ###########################################################
    144 ifndef LOCAL_MODULE_STEM
    145   LOCAL_MODULE_STEM := $(LOCAL_MODULE)
    146 endif
    147 
    148 ifndef LOCAL_BUILT_MODULE_STEM
    149   LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE_STEM)$(LOCAL_MODULE_SUFFIX)
    150 endif
    151 
    152 ifndef LOCAL_INSTALLED_MODULE_STEM
    153   LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE_STEM)$(LOCAL_MODULE_SUFFIX)
    154 endif
    155 
    156 # OVERRIDE_BUILT_MODULE_PATH is only allowed to be used by the
    157 # internal SHARED_LIBRARIES build files.
    158 OVERRIDE_BUILT_MODULE_PATH := $(strip $(OVERRIDE_BUILT_MODULE_PATH))
    159 ifdef 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)
    164 else
    165   built_module_path := $(intermediates)
    166 endif
    167 LOCAL_BUILT_MODULE := $(built_module_path)/$(LOCAL_BUILT_MODULE_STEM)
    168 built_module_path :=
    169 
    170 ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
    171   LOCAL_INSTALLED_MODULE := $(LOCAL_MODULE_PATH)/$(LOCAL_INSTALLED_MODULE_STEM)
    172 endif
    173 
    174 # Assemble the list of targets to create PRIVATE_ variables for.
    175 LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE)
    176 
    177 
    178 ###########################################################
    179 ## AIDL: Compile .aidl files to .java
    180 ###########################################################
    181 
    182 aidl_sources := $(filter %.aidl,$(LOCAL_SRC_FILES))
    183 
    184 ifneq ($(strip $(aidl_sources)),)
    185 
    186 aidl_java_sources := $(patsubst %.aidl,%.java,$(addprefix $(intermediates.COMMON)/src/, $(aidl_sources)))
    187 aidl_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(aidl_sources))
    188 
    189 aidl_preprocess_import :=
    190 LOCAL_SDK_VERSION:=$(strip $(LOCAL_SDK_VERSION))
    191 ifdef LOCAL_SDK_VERSION
    192 ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current)
    193   # LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS
    194   aidl_preprocess_import := $(TARGET_OUT_COMMON_INTERMEDIATES)/framework.aidl
    195 else
    196   aidl_preprocess_import := $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_VERSION)/framework.aidl
    197 endif # !current
    198 else
    199 # build against the platform.
    200 LOCAL_AIDL_INCLUDES += $(FRAMEWORKS_BASE_JAVA_SRC_DIRS)
    201 endif # LOCAL_SDK_VERSION
    202 $(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 
    204 $(aidl_java_sources): $(intermediates.COMMON)/src/%.java: $(TOPDIR)$(LOCAL_PATH)/%.aidl $(LOCAL_ADDITIONAL_DEPENDENCIES) $(AIDL) $(aidl_preprocess_import)
    205 	$(transform-aidl-to-java)
    206 -include $(aidl_java_sources:%.java=%.P)
    207 
    208 else
    209 aidl_java_sources :=
    210 endif
    211 
    212 ###########################################################
    213 ## logtags: Add .logtags files to global list, emit java source
    214 ###########################################################
    215 
    216 logtags_sources := $(filter %.logtags,$(LOCAL_SRC_FILES))
    217 
    218 ifneq ($(strip $(logtags_sources)),)
    219 
    220 event_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".
    224 ifneq ($(strip $(filter $(LOCAL_MODULE_CLASS),APPS JAVA_LIBRARIES)),)
    225 
    226 logtags_java_sources := $(patsubst %.logtags,%.java,$(addprefix $(intermediates.COMMON)/src/, $(logtags_sources)))
    227 logtags_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(logtags_sources))
    228 
    229 $(logtags_java_sources): $(intermediates.COMMON)/src/%.java: $(TOPDIR)$(LOCAL_PATH)/%.logtags $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
    230 	$(transform-logtags-to-java)
    231 
    232 endif
    233 
    234 else
    235 logtags_java_sources :=
    236 event_log_tags :=
    237 endif
    238 
    239 ###########################################################
    240 ## .proto files: Compile proto files to .java
    241 ###########################################################
    242 proto_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.
    245 proto_java_sources_file_stamp :=
    246 ifneq ($(proto_sources),)
    247 proto_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.
    250 ifneq ($(LOCAL_INTERMEDIATE_SOURCE_DIR),)
    251 proto_java_intemediate_dir := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/proto
    252 else
    253 # LOCAL_INTERMEDIATE_SOURCE_DIR may be not defined in non-java modules.
    254 proto_java_intemediate_dir := $(intermediates)/proto
    255 endif
    256 proto_java_sources_file_stamp := $(proto_java_intemediate_dir)/Proto.stamp
    257 proto_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)
    262 ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro)
    263 $(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javamicro_out
    264 else
    265   ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nano)
    266 $(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javanano_out
    267   else
    268 $(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --java_out
    269   endif
    270 endif
    271 $(proto_java_sources_file_stamp): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS)
    272 $(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_PARAMS := $(LOCAL_PROTO_JAVA_OUTPUT_PARAMS)
    273 $(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 
    278 LOCAL_INTERMEDIATE_TARGETS += $(proto_java_sources_file_stamp)
    279 endif # proto_sources
    280 
    281 
    282 ###########################################################
    283 ## Java: Compile .java files to .class
    284 ###########################################################
    285 #TODO: pull this into java.make once host and target are combined
    286 
    287 java_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) $(aidl_java_sources) $(logtags_java_sources) \
    288                 $(filter %.java,$(LOCAL_GENERATED_SOURCES))
    289 all_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.
    296 java_resource_file_groups :=
    297 
    298 LOCAL_JAVA_RESOURCE_DIRS := $(strip $(LOCAL_JAVA_RESOURCE_DIRS))
    299 ifneq ($(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))
    324 endif # LOCAL_JAVA_RESOURCE_DIRS
    325 
    326 LOCAL_JAVA_RESOURCE_FILES := $(strip $(LOCAL_JAVA_RESOURCE_FILES))
    327 ifneq ($(LOCAL_JAVA_RESOURCE_FILES),)
    328   java_resource_file_groups += \
    329     $(foreach f,$(LOCAL_JAVA_RESOURCE_FILES), \
    330 	$(patsubst %/,%,$(dir $(f)))::$(notdir $(f)) \
    331      )
    332 endif # LOCAL_JAVA_RESOURCE_FILES
    333 
    334 ifdef 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.
    343   # Quote the file name to handle special characters (such as #) correctly.
    344   extra_jar_args := \
    345     $(foreach group,$(java_resource_file_groups), \
    346 	$(addprefix -C "$(word 1,$(subst :,$(space),$(group)))" , \
    347 	    $(foreach w, $(wordlist 2,9999,$(subst :,$(space),$(group))), "$(w)" ) \
    348 	) \
    349     )
    350   java_resource_file_groups :=
    351 else
    352   java_resource_sources :=
    353   extra_jar_args :=
    354 endif # java_resource_file_groups
    355 
    356 ## PRIVATE java vars ######################################
    357 # 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.
    360 need_compile_java := $(strip $(all_java_sources)$(all_res_assets))$(LOCAL_STATIC_JAVA_LIBRARIES)$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED))
    361 ifdef need_compile_java
    362 
    363 full_static_java_libs := \
    364     $(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES), \
    365       $(call intermediates-dir-for, \
    366         JAVA_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),COMMON)/javalib.jar)
    367 
    368 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_INSTALL_DIR := $(dir $(LOCAL_INSTALLED_MODULE))
    369 $(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))
    373 ifeq ($(my_prefix),TARGET_)
    374 ifeq ($(LOCAL_SDK_VERSION),)
    375 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,core)
    376 else
    377 ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current)
    378 # LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS.
    379 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,android_stubs_current)
    380 else
    381 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,sdk_v$(LOCAL_SDK_VERSION))
    382 endif # current
    383 endif # LOCAL_SDK_VERSION
    384 endif # TARGET_
    385 $(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.
    395 ifdef LOCAL_IS_HOST_MODULE
    396 ifeq ($(LOCAL_BUILD_HOST_DEX),true)
    397 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,core-hostdex,$(LOCAL_IS_HOST_MODULE))
    398 
    399 full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
    400 full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
    401 else
    402 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH :=
    403 
    404 full_shared_java_libs := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/,\
    405     $(addsuffix $(COMMON_JAVA_PACKAGE_SUFFIX),$(LOCAL_JAVA_LIBRARIES)))
    406 full_java_lib_deps := $(full_shared_java_libs)
    407 endif # LOCAL_BUILD_HOST_DEX
    408 else
    409 full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
    410 full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
    411 endif # !LOCAL_IS_HOST_MODULE
    412 full_java_libs := $(full_shared_java_libs) $(full_static_java_libs) $(LOCAL_CLASSPATH)
    413 full_java_lib_deps += $(full_static_java_libs) $(LOCAL_CLASSPATH)
    414 
    415 # 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.
    417 LOCAL_APK_LIBRARIES := $(strip $(LOCAL_APK_LIBRARIES))
    418 ifdef 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).
    425   full_shared_java_libs += $(link_apk_libraries)
    426   full_java_libs += $(link_apk_libraries)
    427   full_java_lib_deps += $(link_apk_libraries)
    428 endif
    429 
    430 # 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.
    433 LOCAL_INSTRUMENTATION_FOR := $(strip $(LOCAL_INSTRUMENTATION_FOR))
    434 ifdef LOCAL_INSTRUMENTATION_FOR
    435   ifneq ($(words $(LOCAL_INSTRUMENTATION_FOR)),1)
    436     $(error \
    437         $(LOCAL_PATH): Multiple LOCAL_INSTRUMENTATION_FOR members defined)
    438   endif
    439 
    440   link_instr_intermediates_dir.COMMON := $(call intermediates-dir-for, \
    441       APPS,$(LOCAL_INSTRUMENTATION_FOR),,COMMON)
    442   # link against the jar with full original names (before proguard processing).
    443   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)
    446 endif
    447 
    448 jar_manifest_file :=
    449 ifneq ($(strip $(LOCAL_JAR_MANIFEST)),)
    450 jar_manifest_file := $(LOCAL_PATH)/$(LOCAL_JAR_MANIFEST)
    451 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST := $(jar_manifest_file)
    452 else
    453 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST :=
    454 endif
    455 
    456 endif  # need_compile_java
    457 
    458 
    459 ###########################################################
    460 ## make clean- targets
    461 ###########################################################
    462 cleantarget := clean-$(LOCAL_MODULE)
    463 $(cleantarget) : PRIVATE_MODULE := $(LOCAL_MODULE)
    464 $(cleantarget) : PRIVATE_CLEAN_FILES := \
    465     $(LOCAL_BUILT_MODULE) \
    466     $(LOCAL_INSTALLED_MODULE) \
    467     $(intermediates)
    468 $(cleantarget)::
    469 	@echo "Clean: $(PRIVATE_MODULE)"
    470 	$(hide) rm -rf $(PRIVATE_CLEAN_FILES)
    471 
    472 ###########################################################
    473 ## Common definitions for module.
    474 ###########################################################
    475 
    476 # aapt doesn't accept multiple --extra-packages flags.
    477 # We have to collapse them into a single --extra-packages flag here.
    478 LOCAL_AAPT_FLAGS := $(strip $(LOCAL_AAPT_FLAGS))
    479 ifdef LOCAL_AAPT_FLAGS
    480 ifeq ($(filter 0 1,$(words $(filter --extra-packages,$(LOCAL_AAPT_FLAGS)))),)
    481 aapt_flags := $(subst --extra-packages$(space),--extra-packages@,$(LOCAL_AAPT_FLAGS))
    482 aapt_flags_extra_packages := $(patsubst --extra-packages@%,%,$(filter --extra-packages@%,$(aapt_flags)))
    483 aapt_flags_extra_packages := $(sort $(subst :,$(space),$(aapt_flags_extra_packages)))
    484 LOCAL_AAPT_FLAGS := $(filter-out --extra-packages@%,$(aapt_flags)) \
    485     --extra-packages $(subst $(space),:,$(aapt_flags_extra_packages))
    486 aapt_flags_extra_packages :=
    487 aapt_flags :=
    488 endif
    489 endif
    490 
    491 # Propagate local configuration options to this target.
    492 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PATH:=$(LOCAL_PATH)
    493 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_AAPT_FLAGS:= $(LOCAL_AAPT_FLAGS)
    494 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_JAVA_LIBRARIES:= $(LOCAL_JAVA_LIBRARIES)
    495 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MANIFEST_PACKAGE_NAME:= $(LOCAL_MANIFEST_PACKAGE_NAME)
    496 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MANIFEST_INSTRUMENTATION_FOR:= $(LOCAL_MANIFEST_INSTRUMENTATION_FOR)
    497 
    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 
    502 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_INTERMEDIATES_DIR:= $(intermediates)
    503 
    504 # 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.
    518 ifneq ($(strip $(HOST_ACP_UNAVAILABLE)),)
    519   LOCAL_ACP_UNAVAILABLE := $(strip $(HOST_ACP_UNAVAILABLE))
    520 endif
    521 
    522 ifndef 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.
    526 $(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD)
    527 ifneq ($(LOCAL_ACP_UNAVAILABLE),true)
    528 $(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE) | $(ACP)
    529 	@echo "Install: $@"
    530 	$(copy-file-to-new-target)
    531 	$(PRIVATE_POST_INSTALL_CMD)
    532 else
    533 $(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE)
    534 	@echo "Install: $@"
    535 	$(copy-file-to-target-with-cp)
    536 endif
    537 
    538 ifdef LOCAL_DEX_PREOPT
    539 installed_odex := $(basename $(LOCAL_INSTALLED_MODULE)).odex
    540 built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex
    541 $(installed_odex) : $(built_odex) $(LOCAL_BUILT_MODULE) | $(ACP)
    542 	@echo "Install: $@"
    543 	$(copy-file-to-target)
    544 
    545 $(LOCAL_INSTALLED_MODULE) : $(installed_odex)
    546 endif
    547 endif # !LOCAL_UNINSTALLABLE_MODULE
    548 
    549 
    550 ###########################################################
    551 ## CHECK_BUILD goals
    552 ###########################################################
    553 
    554 ifdef java_alternative_checked_module
    555   LOCAL_CHECKED_MODULE := $(java_alternative_checked_module)
    556 endif
    557 
    558 # If nobody has defined a more specific module for the
    559 # checked modules, use LOCAL_BUILT_MODULE.
    560 ifndef LOCAL_CHECKED_MODULE
    561   LOCAL_CHECKED_MODULE := $(LOCAL_BUILT_MODULE)
    562 endif
    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.
    567 ifdef LOCAL_DONT_CHECK_MODULE
    568   LOCAL_CHECKED_MODULE :=
    569 endif
    570 
    571 ###########################################################
    572 ## Register with ALL_MODULES
    573 ###########################################################
    574 
    575 ALL_MODULES += $(LOCAL_MODULE)
    576 
    577 # Don't use += on subvars, or else they'll end up being
    578 # recursively expanded.
    579 ALL_MODULES.$(LOCAL_MODULE).CLASS := \
    580     $(ALL_MODULES.$(LOCAL_MODULE).CLASS) $(LOCAL_MODULE_CLASS)
    581 ALL_MODULES.$(LOCAL_MODULE).PATH := \
    582     $(ALL_MODULES.$(LOCAL_MODULE).PATH) $(LOCAL_PATH)
    583 ALL_MODULES.$(LOCAL_MODULE).TAGS := \
    584     $(ALL_MODULES.$(LOCAL_MODULE).TAGS) $(LOCAL_MODULE_TAGS)
    585 ALL_MODULES.$(LOCAL_MODULE).CHECKED := \
    586     $(ALL_MODULES.$(LOCAL_MODULE).CHECKED) $(LOCAL_CHECKED_MODULE)
    587 ALL_MODULES.$(LOCAL_MODULE).BUILT := \
    588     $(ALL_MODULES.$(LOCAL_MODULE).BUILT) $(LOCAL_BUILT_MODULE)
    589 ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
    590     $(strip $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(LOCAL_INSTALLED_MODULE))
    591 ALL_MODULES.$(LOCAL_MODULE).REQUIRED := \
    592     $(ALL_MODULES.$(LOCAL_MODULE).REQUIRED) $(LOCAL_REQUIRED_MODULES)
    593 ALL_MODULES.$(LOCAL_MODULE).EVENT_LOG_TAGS := \
    594     $(ALL_MODULES.$(LOCAL_MODULE).EVENT_LOG_TAGS) $(event_log_tags)
    595 ALL_MODULES.$(LOCAL_MODULE).INTERMEDIATE_SOURCE_DIR := \
    596     $(ALL_MODULES.$(LOCAL_MODULE).INTERMEDIATE_SOURCE_DIR) $(LOCAL_INTERMEDIATE_SOURCE_DIR)
    597 ALL_MODULES.$(LOCAL_MODULE).MAKEFILE := \
    598     $(ALL_MODULES.$(LOCAL_MODULE).MAKEFILE) $(LOCAL_MODULE_MAKEFILE)
    599 ifdef LOCAL_MODULE_OWNER
    600 ALL_MODULES.$(LOCAL_MODULE).OWNER := \
    601     $(sort $(ALL_MODULES.$(LOCAL_MODULE).OWNER) $(LOCAL_MODULE_OWNER))
    602 endif
    603 
    604 INSTALLABLE_FILES.$(LOCAL_INSTALLED_MODULE).MODULE := $(LOCAL_MODULE)
    605 
    606 ###########################################################
    607 ## Take care of LOCAL_MODULE_TAGS
    608 ###########################################################
    609 
    610 # Keep track of all the tags we've seen.
    611 ALL_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) := \
    618         $(ALL_MODULE_TAGS.$(tag)) \
    619         $(LOCAL_INSTALLED_MODULE)))
    620 
    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 
    625 ###########################################################
    626 ## umbrella targets used to verify builds
    627 ###########################################################
    628 j_or_n :=
    629 ifneq (,$(filter EXECUTABLES SHARED_LIBRARIES STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS)))
    630 j_or_n := native
    631 else
    632 ifneq (,$(filter JAVA_LIBRARIES APPS,$(LOCAL_MODULE_CLASS)))
    633 j_or_n := java
    634 endif
    635 endif
    636 ifdef LOCAL_IS_HOST_MODULE
    637 h_or_t := host
    638 else
    639 h_or_t := target
    640 endif
    641 
    642 ifdef j_or_n
    643 $(j_or_n) $(h_or_t) $(j_or_n)-$(h_or_t) : $(LOCAL_CHECKED_MODULE)
    644 ifneq (,$(filter $(LOCAL_MODULE_TAGS),tests))
    645 $(j_or_n)-$(h_or_t)-tests $(j_or_n)-tests $(h_or_t)-tests : $(LOCAL_CHECKED_MODULE)
    646 endif
    647 endif
    648 
    649 ###########################################################
    650 ## NOTICE files
    651 ###########################################################
    652 
    653 include $(BUILD_NOTICE_FILE)
    654 
    655 #:vi noexpandtab
    656