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 # Catch users that directly include base_rules.mk
     18 $(call record-module-type,base_rules)
     19 
     20 # Users can define base-rules-hook in their buildspec.mk to perform
     21 # arbitrary operations as each module is included.
     22 ifdef base-rules-hook
     23 $(if $(base-rules-hook),)
     24 endif
     25 
     26 ###########################################################
     27 ## Common instructions for a generic module.
     28 ###########################################################
     29 
     30 LOCAL_MODULE := $(strip $(LOCAL_MODULE))
     31 ifeq ($(LOCAL_MODULE),)
     32   $(error $(LOCAL_PATH): LOCAL_MODULE is not defined)
     33 endif
     34 
     35 LOCAL_IS_HOST_MODULE := $(strip $(LOCAL_IS_HOST_MODULE))
     36 LOCAL_IS_AUX_MODULE := $(strip $(LOCAL_IS_AUX_MODULE))
     37 ifdef LOCAL_IS_HOST_MODULE
     38   ifneq ($(LOCAL_IS_HOST_MODULE),true)
     39     $(error $(LOCAL_PATH): LOCAL_IS_HOST_MODULE must be "true" or empty, not "$(LOCAL_IS_HOST_MODULE)")
     40   endif
     41   ifeq ($(LOCAL_HOST_PREFIX),)
     42     my_prefix := HOST_
     43   else
     44     my_prefix := $(LOCAL_HOST_PREFIX)
     45   endif
     46   my_host := host-
     47   my_kind := HOST
     48 else
     49   ifdef LOCAL_IS_AUX_MODULE
     50     ifneq ($(LOCAL_IS_AUX_MODULE),true)
     51       $(error $(LOCAL_PATH): LOCAL_IS_AUX_MODULE must be "true" or empty, not "$(LOCAL_IS_AUX_MODULE)")
     52     endif
     53     my_prefix := AUX_
     54     my_kind := AUX
     55   else
     56     my_prefix := TARGET_
     57     my_kind :=
     58   endif
     59   my_host :=
     60 endif
     61 
     62 ifeq ($(my_prefix),HOST_CROSS_)
     63   my_host_cross := true
     64 else
     65   my_host_cross :=
     66 endif
     67 
     68 ifndef LOCAL_PROPRIETARY_MODULE
     69   LOCAL_PROPRIETARY_MODULE := $(LOCAL_VENDOR_MODULE)
     70 endif
     71 ifndef LOCAL_VENDOR_MODULE
     72   LOCAL_VENDOR_MODULE := $(LOCAL_PROPRIETARY_MODULE)
     73 endif
     74 ifneq ($(filter-out $(LOCAL_PROPRIETARY_MODULE),$(LOCAL_VENDOR_MODULE))$(filter-out $(LOCAL_VENDOR_MODULE),$(LOCAL_PROPRIETARY_MODULE)),)
     75 $(call pretty-error,Only one of LOCAL_PROPRIETARY_MODULE[$(LOCAL_PROPRIETARY_MODULE)] and LOCAL_VENDOR_MODULE[$(LOCAL_VENDOR_MODULE)] may be set, or they must be equal)
     76 endif
     77 
     78 include $(BUILD_SYSTEM)/local_vndk.mk
     79 
     80 my_module_tags := $(LOCAL_MODULE_TAGS)
     81 ifeq ($(my_host_cross),true)
     82   my_module_tags :=
     83 endif
     84 ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
     85 ifdef LOCAL_2ND_ARCH_VAR_PREFIX
     86 # Don't pull in modules by tags if this is for translation TARGET_2ND_ARCH.
     87   my_module_tags :=
     88 endif
     89 endif
     90 
     91 # Ninja has an implicit dependency on the command being run, and kati will
     92 # regenerate the ninja manifest if any read makefile changes, so there is no
     93 # need to have dependencies on makefiles.
     94 # This won't catch all the cases where LOCAL_ADDITIONAL_DEPENDENCIES contains
     95 # a .mk file, because a few users of LOCAL_ADDITIONAL_DEPENDENCIES don't include
     96 # base_rules.mk, but it will fix the most common ones.
     97 LOCAL_ADDITIONAL_DEPENDENCIES := $(filter-out %.mk,$(LOCAL_ADDITIONAL_DEPENDENCIES))
     98 
     99 ###########################################################
    100 ## Validate and define fallbacks for input LOCAL_* variables.
    101 ###########################################################
    102 
    103 ## Dump a .csv file of all modules and their tags
    104 #ifneq ($(tag-list-first-time),false)
    105 #$(shell rm -f tag-list.csv)
    106 #tag-list-first-time := false
    107 #endif
    108 #$(shell echo $(lastword $(filter-out config/% out/%,$(MAKEFILE_LIST))),$(LOCAL_MODULE),$(strip $(LOCAL_MODULE_CLASS)),$(subst $(space),$(comma),$(sort $(my_module_tags))) >> tag-list.csv)
    109 
    110 LOCAL_UNINSTALLABLE_MODULE := $(strip $(LOCAL_UNINSTALLABLE_MODULE))
    111 my_module_tags := $(sort $(my_module_tags))
    112 ifeq (,$(my_module_tags))
    113   my_module_tags := optional
    114 endif
    115 
    116 # User tags are not allowed anymore.  Fail early because it will not be installed
    117 # like it used to be.
    118 ifneq ($(filter $(my_module_tags),user),)
    119   $(warning *** Module name: $(LOCAL_MODULE))
    120   $(warning *** Makefile location: $(LOCAL_MODULE_MAKEFILE))
    121   $(warning * )
    122   $(warning * Module is attempting to use the 'user' tag.  This)
    123   $(warning * used to cause the module to be installed automatically.)
    124   $(warning * Now, the module must be listed in the PRODUCT_PACKAGES)
    125   $(warning * section of a product makefile to have it installed.)
    126   $(warning * )
    127   $(error user tag detected on module.)
    128 endif
    129 
    130 # Only the tags mentioned in this test are expected to be set by module
    131 # makefiles. Anything else is either a typo or a source of unexpected
    132 # behaviors.
    133 ifneq ($(filter-out debug eng tests optional samples,$(my_module_tags)),)
    134 $(call pretty-warning,unusual tags $(my_module_tags))
    135 endif
    136 
    137 # Add implicit tags.
    138 #
    139 # If the local directory or one of its parents contains a MODULE_LICENSE_GPL
    140 # file, tag the module as "gnu".  Search for "*_GPL*", "*_LGPL*" and "*_MPL*"
    141 # so that we can also find files like MODULE_LICENSE_GPL_AND_AFL
    142 #
    143 license_files := $(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*)
    144 gpl_license_file := $(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*_GPL* MODULE_LICENSE*_MPL* MODULE_LICENSE*_LGPL*)
    145 ifneq ($(gpl_license_file),)
    146   my_module_tags += gnu
    147   ALL_GPL_MODULE_LICENSE_FILES := $(sort $(ALL_GPL_MODULE_LICENSE_FILES) $(gpl_license_file))
    148 endif
    149 
    150 LOCAL_MODULE_CLASS := $(strip $(LOCAL_MODULE_CLASS))
    151 ifneq ($(words $(LOCAL_MODULE_CLASS)),1)
    152   $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS must contain exactly one word, not "$(LOCAL_MODULE_CLASS)")
    153 endif
    154 
    155 my_32_64_bit_suffix := $(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT),64,32)
    156 
    157 ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
    158 ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
    159 # When in TARGET_TRANSLATE_2ND_ARCH both TARGET_ARCH and TARGET_2ND_ARCH are 32-bit,
    160 # to avoid path conflict we force using LOCAL_MODULE_PATH_64 for the first arch.
    161 ifdef LOCAL_2ND_ARCH_VAR_PREFIX
    162 my_multilib_module_path := $(LOCAL_MODULE_PATH_32)
    163 else  # ! LOCAL_2ND_ARCH_VAR_PREFIX
    164 my_multilib_module_path := $(LOCAL_MODULE_PATH_64)
    165 endif  # ! LOCAL_2ND_ARCH_VAR_PREFIX
    166 else  # ! TARGET_TRANSLATE_2ND_ARCH
    167 my_multilib_module_path := $(strip $(LOCAL_MODULE_PATH_$(my_32_64_bit_suffix)))
    168 endif # ! TARGET_TRANSLATE_2ND_ARCH
    169 ifdef my_multilib_module_path
    170 my_module_path := $(my_multilib_module_path)
    171 else
    172 my_module_path := $(strip $(LOCAL_MODULE_PATH))
    173 endif
    174 my_module_path := $(patsubst %/,%,$(my_module_path))
    175 my_module_relative_path := $(strip $(LOCAL_MODULE_RELATIVE_PATH))
    176 ifdef LOCAL_IS_HOST_MODULE
    177   partition_tag :=
    178 else
    179 ifeq (true,$(LOCAL_VENDOR_MODULE))
    180   partition_tag := _VENDOR
    181 else ifeq (true,$(LOCAL_OEM_MODULE))
    182   partition_tag := _OEM
    183 else ifeq (true,$(LOCAL_ODM_MODULE))
    184   partition_tag := _ODM
    185 else ifeq (NATIVE_TESTS,$(LOCAL_MODULE_CLASS))
    186   partition_tag := _DATA
    187 else
    188   # The definition of should-install-to-system will be different depending
    189   # on which goal (e.g., sdk or just droid) is being built.
    190   partition_tag := $(if $(call should-install-to-system,$(my_module_tags)),,_DATA)
    191 endif
    192 endif
    193 ifeq ($(my_module_path),)
    194   install_path_var := $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT$(partition_tag)_$(LOCAL_MODULE_CLASS)
    195   ifeq (true,$(LOCAL_PRIVILEGED_MODULE))
    196     install_path_var := $(install_path_var)_PRIVILEGED
    197   endif
    198 
    199   my_module_path := $($(install_path_var))
    200   ifeq ($(strip $(my_module_path)),)
    201     $(error $(LOCAL_PATH): unhandled install path "$(install_path_var) for $(LOCAL_MODULE)")
    202   endif
    203 endif
    204 ifneq ($(my_module_relative_path),)
    205   my_module_path := $(my_module_path)/$(my_module_relative_path)
    206 endif
    207 endif # not LOCAL_UNINSTALLABLE_MODULE
    208 
    209 ifneq ($(strip $(LOCAL_BUILT_MODULE)$(LOCAL_INSTALLED_MODULE)),)
    210   $(error $(LOCAL_PATH): LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE must not be defined by component makefiles)
    211 endif
    212 
    213 my_register_name := $(LOCAL_MODULE)
    214 ifeq ($(my_host_cross),true)
    215   my_register_name := host_cross_$(LOCAL_MODULE)
    216 endif
    217 ifdef LOCAL_2ND_ARCH_VAR_PREFIX
    218 ifndef LOCAL_NO_2ND_ARCH_MODULE_SUFFIX
    219 my_register_name := $(my_register_name)$($(my_prefix)2ND_ARCH_MODULE_SUFFIX)
    220 endif
    221 endif
    222 
    223 ifeq ($(my_host_cross),true)
    224   my_all_targets := host_cross_$(my_register_name)_all_targets
    225 else ifneq ($(LOCAL_IS_HOST_MODULE),)
    226   my_all_targets := host_$(my_register_name)_all_targets
    227 else
    228   my_all_targets := device_$(my_register_name)_all_targets
    229 endif
    230 
    231 # variant is enough to make nano class unique; it serves as a key to lookup (OS,ARCH) tuple
    232 aux_class := $($(my_prefix)OS_VARIANT)
    233 # Make sure that this IS_HOST/CLASS/MODULE combination is unique.
    234 module_id := MODULE.$(if \
    235     $(LOCAL_IS_HOST_MODULE),$($(my_prefix)OS),$(if \
    236     $(LOCAL_IS_AUX_MODULE),$(aux_class),TARGET)).$(LOCAL_MODULE_CLASS).$(my_register_name)
    237 ifdef $(module_id)
    238 $(error $(LOCAL_PATH): $(module_id) already defined by $($(module_id)))
    239 endif
    240 $(module_id) := $(LOCAL_PATH)
    241 
    242 intermediates := $(call local-intermediates-dir,,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))
    243 intermediates.COMMON := $(call local-intermediates-dir,COMMON)
    244 generated_sources_dir := $(call local-generated-sources-dir)
    245 
    246 ifneq ($(LOCAL_OVERRIDES_MODULES),)
    247   ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES)
    248     ifndef LOCAL_IS_HOST_MODULE
    249       EXECUTABLES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_MODULES))
    250     else
    251       $(call pretty-error,host modules cannot use LOCAL_OVERRIDES_MODULES)
    252     endif
    253   else
    254       $(call pretty-error,LOCAL_MODULE_CLASS := $(LOCAL_MODULE_CLASS) cannot use LOCAL_OVERRIDES_MODULES)
    255   endif
    256 endif
    257 
    258 ###########################################################
    259 # Pick a name for the intermediate and final targets
    260 ###########################################################
    261 include $(BUILD_SYSTEM)/configure_module_stem.mk
    262 
    263 LOCAL_BUILT_MODULE := $(intermediates)/$(my_built_module_stem)
    264 
    265 # OVERRIDE_BUILT_MODULE_PATH is only allowed to be used by the
    266 # internal SHARED_LIBRARIES build files.
    267 OVERRIDE_BUILT_MODULE_PATH := $(strip $(OVERRIDE_BUILT_MODULE_PATH))
    268 ifdef OVERRIDE_BUILT_MODULE_PATH
    269   ifneq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
    270     $(error $(LOCAL_PATH): Illegal use of OVERRIDE_BUILT_MODULE_PATH)
    271   endif
    272   $(eval $(call copy-one-file,$(LOCAL_BUILT_MODULE),$(OVERRIDE_BUILT_MODULE_PATH)/$(my_built_module_stem)))
    273 endif
    274 
    275 ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
    276   # Apk and its attachments reside in its own subdir.
    277   ifeq ($(LOCAL_MODULE_CLASS),APPS)
    278   # framework-res.apk doesn't like the additional layer.
    279   ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
    280   # Neither do Runtime Resource Overlay apks, which contain just the overlaid resources.
    281   else ifeq ($(LOCAL_IS_RUNTIME_RESOURCE_OVERLAY),true)
    282   else
    283     my_module_path := $(my_module_path)/$(LOCAL_MODULE)
    284   endif
    285   endif
    286   LOCAL_INSTALLED_MODULE := $(my_module_path)/$(my_installed_module_stem)
    287 endif
    288 
    289 # Assemble the list of targets to create PRIVATE_ variables for.
    290 LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE)
    291 
    292 ###########################################################
    293 ## Create .toc files from shared objects to reduce unnecessary rebuild
    294 # .toc files have the list of external dynamic symbols without their addresses.
    295 # As .KATI_RESTAT is specified to .toc files and commit-change-for-toc is used,
    296 # dependent binaries of a .toc file will be rebuilt only when the content of
    297 # the .toc file is changed.
    298 ###########################################################
    299 ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
    300 LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE).toc
    301 $(LOCAL_BUILT_MODULE).toc: $(LOCAL_BUILT_MODULE)
    302 	$(call $(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)transform-shared-lib-to-toc,$<,$@.tmp)
    303 	$(call commit-change-for-toc,$@)
    304 
    305 # Kati adds restat=1 to ninja. GNU make does nothing for this.
    306 .KATI_RESTAT: $(LOCAL_BUILT_MODULE).toc
    307 # Build .toc file when using mm, mma, or make $(my_register_name)
    308 $(my_all_targets): $(LOCAL_BUILT_MODULE).toc
    309 
    310 ifdef OVERRIDE_BUILT_MODULE_PATH
    311 $(eval $(call copy-one-file,$(LOCAL_BUILT_MODULE).toc,$(OVERRIDE_BUILT_MODULE_PATH)/$(my_built_module_stem).toc))
    312 $(OVERRIDE_BUILT_MODULE_PATH)/$(my_built_module_stem).toc: $(OVERRIDE_BUILT_MODULE_PATH)/$(my_built_module_stem)
    313 endif
    314 endif
    315 
    316 ###########################################################
    317 ## logtags: Add .logtags files to global list
    318 ###########################################################
    319 
    320 logtags_sources := $(filter %.logtags,$(LOCAL_SRC_FILES)) $(LOCAL_LOGTAGS_FILES)
    321 
    322 ifneq ($(strip $(logtags_sources)),)
    323 event_log_tags := $(addprefix $(LOCAL_PATH)/,$(logtags_sources))
    324 else
    325 event_log_tags :=
    326 endif
    327 
    328 ###########################################################
    329 ## make clean- targets
    330 ###########################################################
    331 cleantarget := clean-$(my_register_name)
    332 $(cleantarget) : PRIVATE_MODULE := $(my_register_name)
    333 $(cleantarget) : PRIVATE_CLEAN_FILES := \
    334     $(LOCAL_BUILT_MODULE) \
    335     $(LOCAL_INSTALLED_MODULE) \
    336     $(intermediates)
    337 $(cleantarget)::
    338 	@echo "Clean: $(PRIVATE_MODULE)"
    339 	$(hide) rm -rf $(PRIVATE_CLEAN_FILES)
    340 
    341 ###########################################################
    342 ## Common definitions for module.
    343 ###########################################################
    344 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PATH:=$(LOCAL_PATH)
    345 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_IS_HOST_MODULE := $(LOCAL_IS_HOST_MODULE)
    346 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_IS_AUX_MODULE := $(LOCAL_IS_AUX_MODULE)
    347 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_HOST:= $(my_host)
    348 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PREFIX := $(my_prefix)
    349 
    350 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_INTERMEDIATES_DIR:= $(intermediates)
    351 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_2ND_ARCH_VAR_PREFIX := $(LOCAL_2ND_ARCH_VAR_PREFIX)
    352 
    353 # Tell the module and all of its sub-modules who it is.
    354 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MODULE:= $(my_register_name)
    355 
    356 # Provide a short-hand for building this module.
    357 # We name both BUILT and INSTALLED in case
    358 # LOCAL_UNINSTALLABLE_MODULE is set.
    359 .PHONY: $(my_all_targets)
    360 $(my_all_targets): $(LOCAL_BUILT_MODULE) $(LOCAL_INSTALLED_MODULE)
    361 
    362 .PHONY: $(my_register_name)
    363 $(my_register_name): $(my_all_targets)
    364 
    365 ifneq ($(my_register_name),$(LOCAL_MODULE))
    366 # $(LOCAL_MODULE) covers all the multilib targets.
    367 .PHONY: $(LOCAL_MODULE)
    368 $(LOCAL_MODULE) : $(my_all_targets)
    369 endif
    370 
    371 # Set up phony targets that covers all modules under the given paths.
    372 # This allows us to build everything in given paths by running mmma/mma.
    373 my_path_components := $(subst /,$(space),$(LOCAL_PATH))
    374 my_path_prefix := MODULES-IN
    375 $(foreach c, $(my_path_components),\
    376   $(eval my_path_prefix := $(my_path_prefix)-$(c))\
    377   $(eval .PHONY : $(my_path_prefix))\
    378   $(eval $(my_path_prefix) : $(my_all_targets)))
    379 
    380 ###########################################################
    381 ## Module installation rule
    382 ###########################################################
    383 
    384 my_init_rc_installed :=
    385 my_init_rc_pairs :=
    386 my_installed_symlinks :=
    387 ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
    388 $(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD)
    389 $(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE)
    390 	@echo "Install: $@"
    391 	$(copy-file-to-new-target)
    392 	$(PRIVATE_POST_INSTALL_CMD)
    393 
    394 ifndef LOCAL_IS_HOST_MODULE
    395 # Rule to install the module's companion init.rc.
    396 my_init_rc := $(LOCAL_INIT_RC_$(my_32_64_bit_suffix)) $(LOCAL_INIT_RC)
    397 ifneq ($(strip $(my_init_rc)),)
    398 my_init_rc_pairs := $(foreach rc,$(my_init_rc),$(LOCAL_PATH)/$(rc):$(TARGET_OUT$(partition_tag)_ETC)/init/$(notdir $(rc)))
    399 my_init_rc_installed := $(foreach rc,$(my_init_rc_pairs),$(call word-colon,2,$(rc)))
    400 
    401 # Make sure we only set up the copy rules once, even if another arch variant
    402 # shares a common LOCAL_INIT_RC.
    403 my_init_rc_new_pairs := $(filter-out $(ALL_INIT_RC_INSTALLED_PAIRS),$(my_init_rc_pairs))
    404 my_init_rc_new_installed := $(call copy-many-files,$(my_init_rc_new_pairs))
    405 ALL_INIT_RC_INSTALLED_PAIRS += $(my_init_rc_new_pairs)
    406 
    407 $(my_all_targets) : $(my_init_rc_installed)
    408 endif # my_init_rc
    409 endif # !LOCAL_IS_HOST_MODULE
    410 
    411 # Rule to install the module's companion symlinks
    412 my_installed_symlinks := $(addprefix $(my_module_path)/,$(LOCAL_MODULE_SYMLINKS) $(LOCAL_MODULE_SYMLINKS_$(my_32_64_bit_suffix)))
    413 $(foreach symlink,$(my_installed_symlinks),\
    414     $(call symlink-file,$(LOCAL_INSTALLED_MODULE),$(my_installed_module_stem),$(symlink)))
    415 
    416 $(my_all_targets) : | $(my_installed_symlinks)
    417 
    418 endif # !LOCAL_UNINSTALLABLE_MODULE
    419 
    420 ###########################################################
    421 ## CHECK_BUILD goals
    422 ###########################################################
    423 my_checked_module :=
    424 # If nobody has defined a more specific module for the
    425 # checked modules, use LOCAL_BUILT_MODULE.
    426 ifdef LOCAL_CHECKED_MODULE
    427   my_checked_module := $(LOCAL_CHECKED_MODULE)
    428 else
    429   my_checked_module := $(LOCAL_BUILT_MODULE)
    430 endif
    431 
    432 # If they request that this module not be checked, then don't.
    433 # PLEASE DON'T SET THIS.  ANY PLACES THAT SET THIS WITHOUT
    434 # GOOD REASON WILL HAVE IT REMOVED.
    435 ifdef LOCAL_DONT_CHECK_MODULE
    436   my_checked_module :=
    437 endif
    438 # Don't check build target module defined for the 2nd arch
    439 ifndef LOCAL_IS_HOST_MODULE
    440 ifdef LOCAL_2ND_ARCH_VAR_PREFIX
    441   my_checked_module :=
    442 endif
    443 endif
    444 
    445 ###########################################################
    446 ## Compatibility suite files.
    447 ###########################################################
    448 ifdef LOCAL_COMPATIBILITY_SUITE
    449 
    450 # If we are building a native test or benchmark and its stem variants are not defined,
    451 # separate the multiple architectures into subdirectories of the testcase folder.
    452 arch_dir :=
    453 is_native :=
    454 ifeq ($(LOCAL_MODULE_CLASS),NATIVE_TESTS)
    455   is_native := true
    456 endif
    457 ifeq ($(LOCAL_MODULE_CLASS),NATIVE_BENCHMARK)
    458   is_native := true
    459 endif
    460 ifdef LOCAL_MULTILIB
    461   is_native := true
    462 endif
    463 ifdef is_native
    464   arch_dir := /$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
    465   is_native :=
    466 endif
    467 
    468 # The module itself.
    469 $(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
    470   $(eval my_compat_dist_$(suite) := $(foreach dir, $(call compatibility_suite_dirs,$(suite),$(arch_dir)), \
    471     $(LOCAL_BUILT_MODULE):$(dir)/$(my_installed_module_stem))))
    472 
    473 # Make sure we only add the files once for multilib modules.
    474 ifndef $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files
    475 $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files := true
    476 
    477 # LOCAL_COMPATIBILITY_SUPPORT_FILES is a list of <src>[:<dest>].
    478 $(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
    479   $(eval my_compat_dist_$(suite) += $(foreach f, $(LOCAL_COMPATIBILITY_SUPPORT_FILES), \
    480     $(eval p := $(subst :,$(space),$(f))) \
    481     $(eval s := $(word 1,$(p))) \
    482     $(eval n := $(or $(word 2,$(p)),$(notdir $(word 1, $(p))))) \
    483     $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
    484       $(s):$(dir)/$(n)))))
    485 
    486 
    487 ifneq (,$(wildcard $(LOCAL_PATH)/AndroidTest.xml))
    488 $(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
    489   $(eval my_compat_dist_$(suite) += $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
    490     $(LOCAL_PATH)/AndroidTest.xml:$(dir)/$(LOCAL_MODULE).config)))
    491 endif
    492 
    493 ifneq (,$(wildcard $(LOCAL_PATH)/DynamicConfig.xml))
    494 $(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
    495   $(eval my_compat_dist_$(suite) += $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
    496     $(LOCAL_PATH)/DynamicConfig.xml:$(dir)/$(LOCAL_MODULE).dynamic)))
    497 endif
    498 
    499 ifneq (,$(wildcard $(LOCAL_PATH)/$(LOCAL_MODULE)_*.config))
    500 $(foreach extra_config, $(wildcard $(LOCAL_PATH)/$(LOCAL_MODULE)_*.config), \
    501   $(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
    502     $(eval my_compat_dist_$(suite) += $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
    503       $(extra_config):$(dir)/$(notdir $(extra_config))))))
    504 endif
    505 endif # $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files
    506 
    507 $(call create-suite-dependencies)
    508 
    509 endif  # LOCAL_COMPATIBILITY_SUITE
    510 
    511 ###########################################################
    512 ## Test Data
    513 ###########################################################
    514 my_test_data_pairs :=
    515 my_installed_test_data :=
    516 
    517 ifneq ($(filter NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
    518 ifneq ($(strip $(LOCAL_TEST_DATA)),)
    519 ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
    520 
    521 my_test_data_pairs := $(strip $(foreach td,$(LOCAL_TEST_DATA), \
    522     $(eval _file := $(call word-colon,2,$(td))) \
    523     $(if $(_file), \
    524       $(eval _base := $(call word-colon,1,$(td))), \
    525       $(eval _base := $(LOCAL_PATH)) \
    526         $(eval _file := $(call word-colon,1,$(td)))) \
    527     $(if $(findstring ..,$(_file)),$(error $(LOCAL_MODULE_MAKEFILE): LOCAL_TEST_DATA may not include '..': $(_file))) \
    528     $(if $(filter /%,$(_base) $(_file)),$(error $(LOCAL_MODULE_MAKEFILE): LOCAL_TEST_DATA may not include absolute paths: $(_base) $(_file))) \
    529     $(call append-path,$(_base),$(_file)):$(call append-path,$(my_module_path),$(_file))))
    530 
    531 my_installed_test_data := $(call copy-many-files,$(my_test_data_pairs))
    532 $(LOCAL_INSTALLED_MODULE): $(my_installed_test_data)
    533 
    534 endif
    535 endif
    536 endif
    537 
    538 ###########################################################
    539 ## Register with ALL_MODULES
    540 ###########################################################
    541 
    542 ALL_MODULES += $(my_register_name)
    543 
    544 # Don't use += on subvars, or else they'll end up being
    545 # recursively expanded.
    546 ALL_MODULES.$(my_register_name).CLASS := \
    547     $(ALL_MODULES.$(my_register_name).CLASS) $(LOCAL_MODULE_CLASS)
    548 ALL_MODULES.$(my_register_name).PATH := \
    549     $(ALL_MODULES.$(my_register_name).PATH) $(LOCAL_PATH)
    550 ALL_MODULES.$(my_register_name).TAGS := \
    551     $(ALL_MODULES.$(my_register_name).TAGS) $(my_module_tags)
    552 ALL_MODULES.$(my_register_name).CHECKED := \
    553     $(ALL_MODULES.$(my_register_name).CHECKED) $(my_checked_module)
    554 ALL_MODULES.$(my_register_name).BUILT := \
    555     $(ALL_MODULES.$(my_register_name).BUILT) $(LOCAL_BUILT_MODULE)
    556 ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
    557 ALL_MODULES.$(my_register_name).INSTALLED := \
    558     $(strip $(ALL_MODULES.$(my_register_name).INSTALLED) \
    559     $(LOCAL_INSTALLED_MODULE) $(my_init_rc_installed) $(my_installed_symlinks) \
    560     $(my_installed_test_data))
    561 ALL_MODULES.$(my_register_name).BUILT_INSTALLED := \
    562     $(strip $(ALL_MODULES.$(my_register_name).BUILT_INSTALLED) \
    563     $(LOCAL_BUILT_MODULE):$(LOCAL_INSTALLED_MODULE) \
    564     $(my_init_rc_pairs) $(my_test_data_pairs))
    565 endif
    566 ifdef LOCAL_PICKUP_FILES
    567 # Files or directories ready to pick up by the build system
    568 # when $(LOCAL_BUILT_MODULE) is done.
    569 ALL_MODULES.$(my_register_name).PICKUP_FILES := \
    570     $(ALL_MODULES.$(my_register_name).PICKUP_FILES) $(LOCAL_PICKUP_FILES)
    571 endif
    572 my_required_modules := $(LOCAL_REQUIRED_MODULES) \
    573     $(LOCAL_REQUIRED_MODULES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
    574 ifdef LOCAL_IS_HOST_MODULE
    575 my_required_modules += $(LOCAL_REQUIRED_MODULES_$($(my_prefix)OS))
    576 endif
    577 ALL_MODULES.$(my_register_name).REQUIRED := \
    578     $(strip $(ALL_MODULES.$(my_register_name).REQUIRED) $(my_required_modules))
    579 ALL_MODULES.$(my_register_name).EXPLICITLY_REQUIRED := \
    580     $(strip $(ALL_MODULES.$(my_register_name).EXPLICITLY_REQUIRED)\
    581         $(my_required_modules))
    582 ALL_MODULES.$(my_register_name).EVENT_LOG_TAGS := \
    583     $(ALL_MODULES.$(my_register_name).EVENT_LOG_TAGS) $(event_log_tags)
    584 ALL_MODULES.$(my_register_name).MAKEFILE := \
    585     $(ALL_MODULES.$(my_register_name).MAKEFILE) $(LOCAL_MODULE_MAKEFILE)
    586 ifdef LOCAL_MODULE_OWNER
    587 ALL_MODULES.$(my_register_name).OWNER := \
    588     $(sort $(ALL_MODULES.$(my_register_name).OWNER) $(LOCAL_MODULE_OWNER))
    589 endif
    590 ifdef LOCAL_2ND_ARCH_VAR_PREFIX
    591 ALL_MODULES.$(my_register_name).FOR_2ND_ARCH := true
    592 endif
    593 ALL_MODULES.$(my_register_name).FOR_HOST_CROSS := $(my_host_cross)
    594 
    595 INSTALLABLE_FILES.$(LOCAL_INSTALLED_MODULE).MODULE := $(my_register_name)
    596 
    597 ##########################################################
    598 # Track module-level dependencies.
    599 # Use $(LOCAL_MODULE) instead of $(my_register_name) to ignore module's bitness.
    600 ALL_DEPS.MODULES := $(sort $(ALL_DEPS.MODULES) $(LOCAL_MODULE))
    601 ALL_DEPS.$(LOCAL_MODULE).ALL_DEPS := $(sort \
    602   $(ALL_MODULES.$(LOCAL_MODULE).ALL_DEPS) \
    603   $(LOCAL_STATIC_LIBRARIES) \
    604   $(LOCAL_WHOLE_STATIC_LIBRARIES) \
    605   $(LOCAL_SHARED_LIBRARIES) \
    606   $(LOCAL_HEADER_LIBRARIES) \
    607   $(LOCAL_STATIC_JAVA_LIBRARIES) \
    608   $(LOCAL_JAVA_LIBRARIES)\
    609   $(LOCAL_JNI_SHARED_LIBRARIES))
    610 
    611 ALL_DEPS.$(LOCAL_MODULE).LICENSE := $(sort $(ALL_DEPS.$(LOCAL_MODULE).LICENSE) $(license_files))
    612 
    613 ###########################################################
    614 ## Take care of my_module_tags
    615 ###########################################################
    616 
    617 # Keep track of all the tags we've seen.
    618 ALL_MODULE_TAGS := $(sort $(ALL_MODULE_TAGS) $(my_module_tags))
    619 
    620 # Add this module name to the tag list of each specified tag.
    621 $(foreach tag,$(my_module_tags),\
    622     $(eval ALL_MODULE_NAME_TAGS.$(tag) += $(my_register_name)))
    623 
    624 ###########################################################
    625 ## umbrella targets used to verify builds
    626 ###########################################################
    627 j_or_n :=
    628 ifneq (,$(filter EXECUTABLES SHARED_LIBRARIES STATIC_LIBRARIES HEADER_LIBRARIES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)))
    629 j_or_n := native
    630 else
    631 ifneq (,$(filter JAVA_LIBRARIES APPS,$(LOCAL_MODULE_CLASS)))
    632 j_or_n := java
    633 endif
    634 endif
    635 ifdef LOCAL_IS_HOST_MODULE
    636 h_or_t := host
    637 ifeq ($(my_host_cross),true)
    638 h_or_hc_or_t := host-cross
    639 else
    640 h_or_hc_or_t := host
    641 endif
    642 else
    643 h_or_hc_or_t := target
    644 h_or_t := target
    645 endif
    646 
    647 
    648 ifdef j_or_n
    649 $(j_or_n) $(h_or_t) $(j_or_n)-$(h_or_t) : $(my_checked_module)
    650 ifneq (,$(filter $(my_module_tags),tests))
    651 $(j_or_n)-$(h_or_t)-tests $(j_or_n)-tests $(h_or_t)-tests : $(my_checked_module)
    652 endif
    653 $(LOCAL_MODULE)-$(h_or_hc_or_t) : $(my_all_targets)
    654 ifeq ($(j_or_n),native)
    655 $(LOCAL_MODULE)-$(h_or_hc_or_t)$(my_32_64_bit_suffix) : $(my_all_targets)
    656 endif
    657 endif
    658 
    659 ###########################################################
    660 ## NOTICE files
    661 ###########################################################
    662 
    663 include $(BUILD_NOTICE_FILE)
    664