github.com/westcoastroms/westcoastroms-build@v0.0.0-20190928114312-2350e5a73030/build/make/core/base_rules.mk (about)

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