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