Commits

Stephen Smalley  committed d6e724c Merge

Merge branch 'master' into seandroid

  • Participants
  • Parent commits 092721a, 2bea94b
  • Branches seandroid

Comments (0)

Files changed (28)

File core/64_bit_blacklist.mk

+ifneq ($(TARGET_2ND_ARCH),)
+
+# JNI - needs 64-bit VM
+_64_bit_directory_blacklist += \
+	external/conscrypt \
+	external/neven \
+	external/svox \
+	libcore \
+	packages \
+
+# Chromium/V8: needs 64-bit support
+_64_bit_directory_blacklist += \
+	external/chromium \
+	external/chromium-libpac \
+	external/chromium_org \
+	external/skia \
+	external/v8 \
+	frameworks/webview \
+
+# misc build errors
+_64_bit_directory_blacklist += \
+	external/bluetooth/bluedroid \
+	external/oprofile/opcontrol \
+	external/tcpdump \
+	frameworks/av \
+	frameworks/base \
+	frameworks/ex \
+	frameworks/ml \
+	frameworks/opt \
+	frameworks/wilhelm \
+	device/generic/goldfish/opengl \
+	device/generic/goldfish/camera \
+
+# depends on libnl_2
+_64_bit_directory_blacklist += \
+	external/android-clat \
+	external/wpa_suplicant_8
+
+# depends on frameworks/av
+_64_bit_directory_blacklist += \
+	external/srec \
+	hardware/libhardware_legacy/audio \
+	hardware/libhardware/modules/audio_remote_submix \
+
+_64_bit_directory_blacklist_pattern := $(addsuffix %,$(_64_bit_directory_blacklist))
+
+define directory_is_64_bit_blacklisted
+$(if $(filter $(_64_bit_directory_blacklist_pattern),$(1)),true)
+endef
+else
+define directory_is_64_bit_blacklisted
+endef
+endif

File core/Makefile

 
 INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
 
+# HACK: clear LOCAL_PATH from including last build target before calling
+# intermedites-dir-for
+LOCAL_PATH := $(call my-dir)
+
 recovery_initrc := $(call include-path-for, recovery)/etc/init.rc
 recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
 recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img

File core/binary.mk

 # The following LOCAL_ variables will be modified in this file.
 # Because the same LOCAL_ variables may be used to define modules for both 1st arch and 2nd arch,
 # we can't modify them in place.
-my_src_files := $(LOCAL_SRC_FILES) $(LOCAL_SRC_FILES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
-my_static_libraries := $(LOCAL_STATIC_LIBRARIES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_STATIC_LIBRARIES)
-my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES) $(LOCAL_WHOLE_STATIC_LIBRARIES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
-my_shared_libraries := $(LOCAL_SHARED_LIBRARIES) $(LOCAL_SHARED_LIBRARIES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
-my_32_64_bit_suffix := $(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_IS_64_BIT),64,32)
-my_cflags := $(LOCAL_CFLAGS) $(LOCAL_CFLAGS_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CFLAGS_$(my_32_64_bit_suffix))
+my_src_files := $(LOCAL_SRC_FILES)
+my_static_libraries := $(LOCAL_STATIC_LIBRARIES)
+my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES)
+my_shared_libraries := $(LOCAL_SHARED_LIBRARIES)
+my_cflags := $(LOCAL_CFLAGS)
 my_cppflags := $(LOCAL_CPPFLAGS)
-my_ldflags := $(LOCAL_LDFLAGS) $(LOCAL_LDFLAGS_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_LDFLAGS_$(my_32_64_bit_suffix))
-my_asflags := $(LOCAL_ASFLAGS) $(LOCAL_ASFLAGS_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_ASFLAGS_$(my_32_64_bit_suffix))
+my_ldflags := $(LOCAL_LDFLAGS)
+my_asflags := $(LOCAL_ASFLAGS)
 my_cc := $(LOCAL_CC)
 my_cxx := $(LOCAL_CXX)
-my_c_includes := $(LOCAL_C_INCLUDES) $(LOCAL_C_INCLUDES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_C_INCLUDES_$(my_32_64_bit_suffix))
-my_generated_sources := $(LOCAL_GENERATED_SOURCES) $(LOCAL_GENERATED_SOURCES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
+my_c_includes := $(LOCAL_C_INCLUDES)
+my_generated_sources := $(LOCAL_GENERATED_SOURCES)
+
+ifndef LOCAL_IS_HOST_MODULE
+my_32_64_bit_suffix := $(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_IS_64_BIT),64,32)
+
+my_src_files += $(LOCAL_SRC_FILES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_$(my_32_64_bit_suffix))
+my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SHARED_LIBRARIES_$(my_32_64_bit_suffix))
+my_cflags += $(LOCAL_CFLAGS_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CFLAGS_$(my_32_64_bit_suffix))
+my_cppflags += $(LOCAL_CPPFLAGS_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CPPFLAGS_$(my_32_64_bit_suffix))
+my_ldflags += $(LOCAL_LDFLAGS_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_LDFLAGS_$(my_32_64_bit_suffix))
+my_asflags += $(LOCAL_ASFLAGS_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_ASFLAGS_$(my_32_64_bit_suffix))
+my_c_includes += $(LOCAL_C_INCLUDES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_C_INCLUDES_$(my_32_64_bit_suffix))
+my_generated_sources += $(LOCAL_GENERATED_SOURCES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_GENERATED_SOURCES_$(my_32_64_bit_suffix))
+
+# arch-specific static libraries go first so that generic ones can depend on them
+my_static_libraries := $(LOCAL_STATIC_LIBRARIES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_static_libraries)
+my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_WHOLE_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_whole_static_libraries)
 
 my_cflags := $(filter-out $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_UNSUPPORTED_CFLAGS),$(my_cflags))
+endif
 
 # The real dependency will be added after all Android.mks are loaded and the install paths
 # of the shared libraries are determined.
 
 all_objects := $(normal_objects) $(gen_o_objects)
 
-my_c_includes += $(TOPDIR)$(LOCAL_PATH) $(intermediates)
+my_c_includes += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(generated_sources_dir)
 
 ifndef LOCAL_SDK_VERSION
   my_c_includes += $(JNI_H_INCLUDE)

File core/clang/TARGET_x86.mk

 include $(BUILD_SYSTEM)/clang/x86.mk
 
 CLANG_CONFIG_x86_TARGET_TRIPLE := i686-linux-android
+# NOTE: There is no i686-linux-android prebuilt, so we must hardcode the
+# x86_64 target instead.
 CLANG_CONFIG_x86_TARGET_TOOLCHAIN_PREFIX := \
   $($(clang_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT)/x86_64-linux-android/bin
 

File core/clear_vars.mk

 LOCAL_NO_STATIC_ANALYZER:=
 LOCAL_32_BIT_ONLY:= # '',true
 LOCAL_NO_2ND_ARCH:= # '',true
+LOCAL_MODULE_TARGET_ARCH:=
+LOCAL_MODULE_TARGET_ARCH_WARN:=
+LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH:=
+LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH_WARN:=
 
 # arch specific variables
 LOCAL_SRC_FILES_$(TARGET_ARCH):=
 LOCAL_CFLAGS_$(TARGET_ARCH):=
+LOCAL_CPPFLAGS_$(TARGET_ARCH):=
 LOCAL_C_INCLUDES_$(TARGET_ARCH):=
 LOCAL_ASFLAGS_$(TARGET_ARCH):=
 LOCAL_NO_CRT_$(TARGET_ARCH):=
 ifdef TARGET_2ND_ARCH
 LOCAL_SRC_FILES_$(TARGET_2ND_ARCH):=
 LOCAL_CFLAGS_$(TARGET_2ND_ARCH):=
+LOCAL_CPPFLAGS_$(TARGET_2ND_ARCH):=
 LOCAL_C_INCLUDES_$(TARGET_2ND_ARCH):=
 LOCAL_ASFLAGS_$(TARGET_2ND_ARCH):=
 LOCAL_NO_CRT_$(TARGET_2ND_ARCH):=
 LOCAL_REQUIRED_MODULES_$(TARGET_2ND_ARCH):=
 endif
 
+LOCAL_SRC_FILES_32:=
+LOCAL_SRC_FILES_64:=
+LOCAL_SHARED_LIBRARIES_32:=
+LOCAL_SHARED_LIBRARIES_64:=
+LOCAL_STATIC_LIBRARIES_32:=
+LOCAL_STATIC_LIBRARIES_64:=
+LOCAL_WHOLE_STATIC_LIBRARIES_32:=
+LOCAL_WHOLE_STATIC_LIBRARIES_64:=
+LOCAL_GENERATED_SOURCES_32:=
+LOCAL_GENERATED_SOURCES_64:=
 LOCAL_CFLAGS_32:=
 LOCAL_CFLAGS_64:=
+LOCAL_CPPFLAGS_32:=
+LOCAL_CPPFLAGS_64:=
 LOCAL_LDFLAGS_32:=
 LOCAL_LDFLAGS_64:=
 LOCAL_ASFLAGS_32:=

File core/combo/TARGET_linux-x86.mk

 	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
 	 -nostdlib -Wl,-soname,$(notdir $@) \
 	 -shared -Bsymbolic \
-	$(TARGET_GLOBAL_CFLAGS) \
 	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
 	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \
 	$(PRIVATE_ALL_OBJECTS) \

File core/combo/TARGET_linux-x86_64.mk

 	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
 	 -nostdlib -Wl,-soname,$(notdir $@) \
 	 -shared -Bsymbolic \
-	$(TARGET_GLOBAL_CFLAGS) \
 	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
 	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \
 	$(PRIVATE_ALL_OBJECTS) \

File core/definitions.mk

 endef
 
 ###########################################################
-## Set up the dependencies for a prebuilt target
-##  $(call add-prebuilt-file, srcfile, [targetclass])
-###########################################################
-
-define add-prebuilt-file
-    $(eval $(include-prebuilt))
-endef
-
-define include-prebuilt
-    include $$(CLEAR_VARS)
-    LOCAL_SRC_FILES := $(1)
-    LOCAL_BUILT_MODULE_STEM := $(1)
-    LOCAL_MODULE_SUFFIX := $$(suffix $(1))
-    LOCAL_MODULE := $$(basename $(1))
-    LOCAL_MODULE_CLASS := $(2)
-    include $$(BUILD_PREBUILT)
-endef
-
-###########################################################
-## do multiple prebuilts
-##  $(call target class, files ...)
-###########################################################
-
-define add-prebuilt-files
-    $(foreach f,$(2),$(call add-prebuilt-file,$f,$(1)))
-endef
-
-
-
-###########################################################
 ## The intermediates directory.  Where object files go for
 ## a given target.  We could technically get away without
 ## the "_intermediates" suffix on the directory, but it's
     $(if $(_idfName),, \
         $(error $(LOCAL_PATH): Name not defined in call to intermediates-dir-for)) \
     $(eval _idfPrefix := $(if $(strip $(3)),HOST,TARGET)) \
-    $(eval _idf2ndArchPrefix := $(if $(strip $(5)),$(TARGET_2ND_ARCH_VAR_PREFIX))) \
+    $(eval _idf2ndArchPrefix := $(if $(call directory_is_64_bit_blacklisted,$(LOCAL_PATH))$(strip $(5)),$(TARGET_2ND_ARCH_VAR_PREFIX))) \
     $(if $(filter $(_idfPrefix)-$(_idfClass),$(COMMON_MODULE_CLASSES))$(4), \
         $(eval _idfIntBase := $($(_idfPrefix)_OUT_COMMON_INTERMEDIATES)) \
-      , \
-        $(eval _idfIntBase := $($(_idf2ndArchPrefix)$(_idfPrefix)_OUT_INTERMEDIATES)) \
+      ,$(if $(filter $(_idfPrefix)-$(_idfClass),TARGET-SHARED_LIBRARIES TARGET-STATIC_LIBRARIES TARGET-EXECUTABLES),\
+          $(eval _idfIntBase := $($(_idf2ndArchPrefix)$(_idfPrefix)_OUT_INTERMEDIATES)) \
+       ,$(eval _idfIntBase := $($(_idfPrefix)_OUT_INTERMEDIATES)) \
+       ) \
      ) \
     $(_idfIntBase)/$(_idfClass)/$(_idfName)_intermediates \
 )

File core/executable.mk

 endif
 endif
 
-ifeq ($(TARGET_IS_64_BIT)|$(LOCAL_32_BIT_ONLY),true|true)
+LOCAL_NO_2ND_ARCH_MODULE_SUFFIX := true
+
+# check if primary arch is supported
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+ifeq ($(my_module_arch_supported),true)
+# primary arch is supported
+include $(BUILD_SYSTEM)/executable_internal.mk
+else ifneq (,$(TARGET_2ND_ARCH))
+# check if secondary arch is supported
 LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX)
-else
-LOCAL_2ND_ARCH_VAR_PREFIX :=
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+ifeq ($(my_module_arch_supported),true)
+# secondary arch is supported
+include $(BUILD_SYSTEM)/executable_internal.mk
 endif
+endif # TARGET_2ND_ARCH
 
-LOCAL_NO_2ND_ARCH_MODULE_SUFFIX := true
-include $(BUILD_SYSTEM)/executable_internal.mk
 LOCAL_2ND_ARCH_VAR_PREFIX :=
 LOCAL_NO_2ND_ARCH_MODULE_SUFFIX :=
+
+my_module_arch_supported :=

File core/main.mk

 # and host information.
 include $(BUILD_SYSTEM)/config.mk
 
+include $(BUILD_SYSTEM)/64_bit_blacklist.mk
+
 # This allows us to force a clean build - included after the config.mk
 # environment setup is done, but before we generate any dependencies.  This
 # file does the rm -rf inline so the deps which are all done below will
   $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES), \
     $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\
       $(eval dangling_modules += $(m))))
+  ifneq ($(TARGET_IS_64_BIT),true)
+    # We know those 64-bit modules don't exist in the 32-bit SDK build.
+    dangling_modules := $(filter-out %64,$(dangling_modules))
+  endif
   ifneq ($(dangling_modules),)
     $(error Module names '$(dangling_modules)' in PRODUCT_PACKAGES has nothing to install!)
   endif

File core/module_arch_supported.mk

+###########################################################
+## Determine if a module can be built for an arch
+##
+## Inputs from module makefile:
+## LOCAL_32_BIT_ONLY
+## LOCAL_NO_2ND_ARCH
+## LOCAL_MODULE_TARGET_ARCH
+## LOCAL_MODULE_TARGET_ARCH_WARN
+## LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH
+## LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH_WARN
+##
+## Inputs from build system:
+## TARGET_IS_64_BIT
+## LOCAL_2ND_ARCH_VAR_PREFIX
+##
+## Outputs:
+## my_module_arch_supported := (true|false)
+###########################################################
+
+my_module_arch_supported := true
+
+ifeq ($(LOCAL_2ND_ARCH_VAR_PREFIX),)
+ifeq ($(TARGET_IS_64_BIT)|$(LOCAL_32_BIT_ONLY),true|true)
+my_module_arch_supported := false
+else ifeq ($(call directory_is_64_bit_blacklisted,$(LOCAL_PATH)),true)
+my_module_arch_supported := false
+endif
+else # LOCAL_2ND_ARCH_VAR_PREFIX
+ifeq ($(LOCAL_NO_2ND_ARCH),true)
+my_module_arch_supported := false
+endif
+endif # !LOCAL_2ND_ARCH_VAR_PREFIX
+
+ifneq (,$(LOCAL_MODULE_TARGET_ARCH))
+ifeq (,$(filter $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),$(LOCAL_MODULE_TARGET_ARCH)))
+my_module_arch_supported := false
+endif
+endif
+
+ifneq (,$(LOCAL_MODULE_TARGET_ARCH_WARN))
+ifeq (,$(filter $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),$(LOCAL_MODULE_TARGET_ARCH_WARN)))
+my_module_arch_supported := false
+$(warning $(LOCAL_MODULE): architecture $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) not supported)
+endif
+endif
+
+ifneq (,$(filter $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),$(LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH)))
+my_module_arch_supported := false
+endif
+
+ifneq (,$(filter $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),$(LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH_WARN)))
+my_module_arch_supported := false
+$(warning $(LOCAL_MODULE): architecture $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) unsupported)
+endif

File core/package.mk

-#
-# Copyright (C) 2008 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-###########################################################
-## Standard rules for building an application package.
-##
-## Additional inputs from base_rules.make:
-## LOCAL_PACKAGE_NAME: The name of the package; the directory
-## will be called this.
-##
-## MODULE, MODULE_PATH, and MODULE_SUFFIX will
-## be set for you.
-###########################################################
-
-ifeq ($(TARGET_IS_64_BIT)|$(LOCAL_32_BIT_ONLY),true|true)
-LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX)
-else
-LOCAL_2ND_ARCH_VAR_PREFIX :=
-endif
+# We don't automatically set up rules to build packages for both
+# TARGET_ARCH and TARGET_2ND_ARCH.
+# By default, an package is built for TARGET_ARCH.
+# To build it for TARGET_2ND_ARCH in a 64bit product, use "LOCAL_32_BIT_ONLY := true".
 
 LOCAL_NO_2ND_ARCH_MODULE_SUFFIX := true
 
-# If this makefile is being read from within an inheritance,
-# use the new values.
-skip_definition:=
-ifdef LOCAL_PACKAGE_OVERRIDES
-  package_overridden := $(call set-inherited-package-variables)
-  ifeq ($(strip $(package_overridden)),)
-    skip_definition := true
-  endif
-endif
-
-ifndef skip_definition
-
-LOCAL_PACKAGE_NAME := $(strip $(LOCAL_PACKAGE_NAME))
-ifeq ($(LOCAL_PACKAGE_NAME),)
-$(error $(LOCAL_PATH): Package modules must define LOCAL_PACKAGE_NAME)
-endif
-
-ifneq ($(strip $(LOCAL_MODULE_SUFFIX)),)
-$(error $(LOCAL_PATH): Package modules may not define LOCAL_MODULE_SUFFIX)
-endif
-LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
-
-ifneq ($(strip $(LOCAL_MODULE)),)
-$(error $(LOCAL_PATH): Package modules may not define LOCAL_MODULE)
-endif
-LOCAL_MODULE := $(LOCAL_PACKAGE_NAME)
-
-ifeq ($(strip $(LOCAL_MANIFEST_FILE)),)
-LOCAL_MANIFEST_FILE := AndroidManifest.xml
-endif
-
-# If you need to put the MANIFEST_FILE outside of LOCAL_PATH
-# you can use FULL_MANIFEST_FILE
-ifeq ($(strip $(LOCAL_FULL_MANIFEST_FILE)),)
-LOCAL_FULL_MANIFEST_FILE := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE)
-endif
-
-ifneq ($(strip $(LOCAL_MODULE_CLASS)),)
-$(error $(LOCAL_PATH): Package modules may not set LOCAL_MODULE_CLASS)
-endif
-LOCAL_MODULE_CLASS := APPS
-
-# Package LOCAL_MODULE_TAGS default to optional
-LOCAL_MODULE_TAGS := $(strip $(LOCAL_MODULE_TAGS))
-ifeq ($(LOCAL_MODULE_TAGS),)
-LOCAL_MODULE_TAGS := optional
-endif
-
-ifeq ($(filter tests, $(LOCAL_MODULE_TAGS)),)
-# Force localization check if it's not tagged as tests.
-LOCAL_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) -z
-endif
-
-ifeq (,$(LOCAL_ASSET_DIR))
-LOCAL_ASSET_DIR := $(LOCAL_PATH)/assets
-endif
-
-ifeq (,$(LOCAL_RESOURCE_DIR))
-  LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-endif
-
-package_resource_overlays := $(strip \
-    $(wildcard $(foreach dir, $(PRODUCT_PACKAGE_OVERLAYS), \
-      $(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))) \
-    $(wildcard $(foreach dir, $(DEVICE_PACKAGE_OVERLAYS), \
-      $(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))))
-
-LOCAL_RESOURCE_DIR := $(package_resource_overlays) $(LOCAL_RESOURCE_DIR)
-
-all_assets := $(call find-subdir-assets,$(LOCAL_ASSET_DIR))
-all_assets := $(addprefix $(LOCAL_ASSET_DIR)/,$(patsubst assets/%,%,$(all_assets)))
-
-all_resources := $(strip \
-    $(foreach dir, $(LOCAL_RESOURCE_DIR), \
-      $(addprefix $(dir)/, \
-        $(patsubst res/%,%, \
-          $(call find-subdir-assets,$(dir)) \
-         ) \
-       ) \
-     ))
-
-all_res_assets := $(strip $(all_assets) $(all_resources))
-
-package_expected_intermediates_COMMON := $(call local-intermediates-dir,COMMON)
-# If no assets or resources were found, clear the directory variables so
-# we don't try to build them.
-ifeq (,$(all_assets))
-LOCAL_ASSET_DIR:=
-endif
-ifeq (,$(all_resources))
-LOCAL_RESOURCE_DIR:=
-R_file_stamp :=
-else
-# Make sure that R_file_stamp inherits the proper PRIVATE vars.
-# If R.stamp moves, be sure to update the framework makefile,
-# which has intimate knowledge of its location.
-R_file_stamp := $(package_expected_intermediates_COMMON)/src/R.stamp
-LOCAL_INTERMEDIATE_TARGETS += $(R_file_stamp)
-endif
-
-LOCAL_BUILT_MODULE_STEM := package.apk
-
-LOCAL_PROGUARD_ENABLED:=$(strip $(LOCAL_PROGUARD_ENABLED))
-ifndef LOCAL_PROGUARD_ENABLED
-ifneq ($(DISABLE_PROGUARD),true)
-    LOCAL_PROGUARD_ENABLED :=full
-endif
-endif
-ifeq ($(LOCAL_PROGUARD_ENABLED),disabled)
-    # the package explicitly request to disable proguard.
-    LOCAL_PROGUARD_ENABLED :=
-endif
-proguard_options_file :=
-ifneq ($(LOCAL_PROGUARD_ENABLED),custom)
-ifneq ($(all_resources),)
-    proguard_options_file := $(package_expected_intermediates_COMMON)/proguard_options
-endif # all_resources
-endif # !custom
-LOCAL_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_PROGUARD_FLAGS)
-
-ifeq (true,$(EMMA_INSTRUMENT))
-ifndef LOCAL_EMMA_INSTRUMENT
-# No emma for test apks.
-ifeq (,$(filer tests,$(LOCAL_MODULE_TAGS))$(LOCAL_INSTRUMENTATION_FOR))
-LOCAL_EMMA_INSTRUMENT := true
-endif # No test apk
-endif # LOCAL_EMMA_INSTRUMENT is not set
-else
-LOCAL_EMMA_INSTRUMENT := false
-endif # EMMA_INSTRUMENT is true
-
-ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
-ifeq (true,$(EMMA_INSTRUMENT_STATIC))
-LOCAL_STATIC_JAVA_LIBRARIES += emma
-else
-ifdef LOCAL_SDK_VERSION
-ifdef TARGET_BUILD_APPS
-# In unbundled build merge the emma library into the apk.
-LOCAL_STATIC_JAVA_LIBRARIES += emma
-else
-# If build against the SDK in full build, core.jar is not used,
-# we have to use prebiult emma.jar to make Proguard happy;
-# Otherwise emma classes are included in core.jar.
-LOCAL_PROGUARD_FLAGS += -libraryjars $(EMMA_JAR)
-endif # full build
-endif # LOCAL_SDK_VERSION
-endif # EMMA_INSTRUMENT_STATIC
-endif # LOCAL_EMMA_INSTRUMENT
-
-rs_compatibility_jni_libs :=
-
-#################################
-include $(BUILD_SYSTEM)/java.mk
-#################################
-
-LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION))
-ifeq ($(LOCAL_SDK_RES_VERSION),)
-  LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION)
-endif
-
-full_android_manifest := $(LOCAL_FULL_MANIFEST_FILE)
-$(LOCAL_INTERMEDIATE_TARGETS): \
-    PRIVATE_ANDROID_MANIFEST := $(full_android_manifest)
-ifneq (,$(filter-out current, $(LOCAL_SDK_VERSION)))
-$(LOCAL_INTERMEDIATE_TARGETS): \
-    PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION)
-else
-$(LOCAL_INTERMEDIATE_TARGETS): \
-    PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK)
-endif
-
-ifneq ($(all_resources),)
-
-# Since we don't know where the real R.java file is going to end up,
-# we need to use another file to stand in its place.  We'll just
-# copy the generated file to src/R.stamp, which means it will
-# have the same contents and timestamp as the actual file.
-#
-# At the same time, this will copy the R.java file to a central
-# 'R' directory to make it easier to add the files to an IDE.
-#
-#TODO: use PRIVATE_SOURCE_INTERMEDIATES_DIR instead of
-#      $(intermediates.COMMON)/src
-ifneq ($(package_expected_intermediates_COMMON),$(intermediates.COMMON))
-  $(error $(LOCAL_MODULE): internal error: expected intermediates.COMMON "$(package_expected_intermediates_COMMON)" != intermediates.COMMON "$(intermediates.COMMON)")
-endif
-
-$(R_file_stamp): PRIVATE_RESOURCE_PUBLICS_OUTPUT := \
-			$(intermediates.COMMON)/public_resources.xml
-$(R_file_stamp): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file)
-$(R_file_stamp): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT) | $(ACP)
-	@echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)"
-	@rm -f $@
-	$(create-resource-java-files)
-	$(hide) for GENERATED_MANIFEST_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \
-					-name Manifest.java 2> /dev/null`; do \
-		dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_MANIFEST_FILE`; \
-		mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \
-		$(ACP) -fp $$GENERATED_MANIFEST_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \
-	done;
-	$(hide) for GENERATED_R_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \
-					-name R.java 2> /dev/null`; do \
-		dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_R_FILE`; \
-		mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \
-		$(ACP) -fp $$GENERATED_R_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir \
-			|| exit 31; \
-		$(ACP) -fp $$GENERATED_R_FILE $@ || exit 32; \
-	done; \
-
-$(proguard_options_file): $(R_file_stamp)
-
-ifdef LOCAL_EXPORT_PACKAGE_RESOURCES
-# Put this module's resources into a PRODUCT-agnositc package that
-# other packages can use to build their own PRODUCT-agnostic R.java (etc.)
-# files.
-resource_export_package := $(intermediates.COMMON)/package-export.apk
-$(R_file_stamp): $(resource_export_package)
-
-# add-assets-to-package looks at PRODUCT_AAPT_CONFIG, but this target
-# can't know anything about PRODUCT.  Clear it out just for this target.
-$(resource_export_package): PRIVATE_PRODUCT_AAPT_CONFIG :=
-$(resource_export_package): PRIVATE_PRODUCT_AAPT_PREF_CONFIG :=
-$(resource_export_package): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT)
-	@echo "target Export Resources: $(PRIVATE_MODULE) ($@)"
-	$(create-empty-package)
-	$(add-assets-to-package)
-endif
-
-# Other modules should depend on the BUILT module if
-# they want to use this module's R.java file.
-$(LOCAL_BUILT_MODULE): $(R_file_stamp)
-
-ifneq ($(full_classes_jar),)
-# If full_classes_jar is non-empty, we're building sources.
-# If we're building sources, the initial javac step (which
-# produces full_classes_compiled_jar) needs to ensure the
-# R.java and Manifest.java files have been generated first.
-$(full_classes_compiled_jar): $(R_file_stamp)
-endif
-
-endif  # all_resources
-
-ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
-# We need to explicitly clear this var so that we don't
-# inherit the value from whomever caused us to be built.
-$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_INCLUDES :=
-else
-# Most packages should link against the resources defined by framework-res.
-# Even if they don't have their own resources, they may use framework
-# resources.
-ifneq ($(filter-out current,$(LOCAL_SDK_RES_VERSION))$(if $(TARGET_BUILD_APPS),$(filter current,$(LOCAL_SDK_RES_VERSION))),)
-# for released sdk versions, the platform resources were built into android.jar.
-framework_res_package_export := \
-    $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_RES_VERSION)/android.jar
-framework_res_package_export_deps := $(framework_res_package_export)
-else # LOCAL_SDK_RES_VERSION
-framework_res_package_export := \
-    $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
-# We can't depend directly on the export.apk file; it won't get its
-# PRIVATE_ vars set up correctly if we do.  Instead, depend on the
-# corresponding R.stamp file, which lists the export.apk as a dependency.
-framework_res_package_export_deps := \
-    $(dir $(framework_res_package_export))src/R.stamp
-endif # LOCAL_SDK_RES_VERSION
-$(R_file_stamp): $(framework_res_package_export_deps)
-$(LOCAL_INTERMEDIATE_TARGETS): \
-    PRIVATE_AAPT_INCLUDES := $(framework_res_package_export)
-endif # LOCAL_NO_STANDARD_LIBRARIES
-
-ifneq ($(full_classes_jar),)
-$(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex)
-$(LOCAL_BUILT_MODULE): $(built_dex)
-endif # full_classes_jar
-
-
-# Get the list of jni libraries to be included in the apk file.
-
-so_suffix := $($(my_prefix)SHLIB_SUFFIX)
-
-jni_shared_libraries := \
-    $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
-      $(addsuffix $(so_suffix), \
-        $(LOCAL_JNI_SHARED_LIBRARIES)))
-
-# Include RS dynamically-generated libraries as well
-# Keep this ifneq, as the += otherwise adds spaces that need to be stripped.
-ifneq ($(rs_compatibility_jni_libs),)
-jni_shared_libraries += $(rs_compatibility_jni_libs)
-endif
-
-# App explicitly requires the prebuilt NDK libstlport_shared.so.
-# libstlport_shared.so should never go to the system image.
-# Instead it should be packaged into the apk.
-ifeq (stlport_shared,$(LOCAL_NDK_STL_VARIANT))
-ifndef LOCAL_SDK_VERSION
-$(error LOCAL_SDK_VERSION has to be defined together with LOCAL_NDK_STL_VARIANT, \
-    LOCAL_PACKAGE_NAME=$(LOCAL_PACKAGE_NAME))
-endif
-jni_shared_libraries += \
-    $(HISTORICAL_NDK_VERSIONS_ROOT)/current/sources/cxx-stl/stlport/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libstlport_shared.so
-endif
-
-# Set the abi directory used by the local JNI shared libraries.
-# (Doesn't change how the local shared libraries are compiled, just
-# sets where they are stored in the apk.)
-
-ifeq ($(LOCAL_JNI_SHARED_LIBRARIES_ABI),)
-    jni_shared_libraries_abi := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)
-else
-    jni_shared_libraries_abi := $(LOCAL_JNI_SHARED_LIBRARIES_ABI)
-endif
-
-# Pick a key to sign the package with.  If this package hasn't specified
-# an explicit certificate, use the default.
-# Secure release builds will have their packages signed after the fact,
-# so it's ok for these private keys to be in the clear.
-ifeq ($(LOCAL_CERTIFICATE),)
-    LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
-endif
-
-ifeq ($(LOCAL_CERTIFICATE),EXTERNAL)
-  # The special value "EXTERNAL" means that we will sign it with the
-  # default devkey, apply predexopt, but then expect the final .apk
-  # (after dexopting) to be signed by an outside tool.
-  LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
-  PACKAGES.$(LOCAL_PACKAGE_NAME).EXTERNAL_KEY := 1
-endif
-
-# If this is not an absolute certificate, assign it to a generic one.
-ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./)
-    LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE)
-endif
-private_key := $(LOCAL_CERTIFICATE).pk8
-certificate := $(LOCAL_CERTIFICATE).x509.pem
-
-$(LOCAL_BUILT_MODULE): $(private_key) $(certificate) $(SIGNAPK_JAR)
-$(LOCAL_BUILT_MODULE): PRIVATE_PRIVATE_KEY := $(private_key)
-$(LOCAL_BUILT_MODULE): PRIVATE_CERTIFICATE := $(certificate)
-
-PACKAGES.$(LOCAL_PACKAGE_NAME).PRIVATE_KEY := $(private_key)
-PACKAGES.$(LOCAL_PACKAGE_NAME).CERTIFICATE := $(certificate)
-
-$(LOCAL_BUILT_MODULE): PRIVATE_ADDITIONAL_CERTIFICATES := $(foreach c,\
-    $(LOCAL_ADDITIONAL_CERTIFICATES), $(c).x509.pem $(c).pk8)
-
-# Define the rule to build the actual package.
-$(LOCAL_BUILT_MODULE): $(AAPT) | $(ZIPALIGN)
-ifdef LOCAL_DEX_PREOPT
-$(LOCAL_BUILT_MODULE): PRIVATE_DEX_LOCATION := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
-$(LOCAL_BUILT_MODULE): PRIVATE_BUILT_ODEX := $(built_odex)
-$(LOCAL_BUILT_MODULE): PRIVATE_DEX_PREOPT_IMAGE := $(LOCAL_DEX_PREOPT_IMAGE)
-# Make sure the boot jars get dexpreopt-ed first
-$(LOCAL_BUILT_MODULE) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT)
-$(LOCAL_BUILT_MODULE) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS)
-$(LOCAL_BUILT_MODULE) : $(LOCAL_DEX_PREOPT_IMAGE)
-
-# built_odex is byproduct of LOCAL_BUILT_MODULE without its own build recipe.
-$(built_odex) : $(LOCAL_BUILT_MODULE)
-endif
-$(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES := $(jni_shared_libraries)
-$(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES_ABI := $(jni_shared_libraries_abi)
-ifneq ($(TARGET_BUILD_APPS),)
-    # Include all resources for unbundled apps.
-    LOCAL_AAPT_INCLUDE_ALL_RESOURCES := true
-endif
-ifeq ($(LOCAL_AAPT_INCLUDE_ALL_RESOURCES),true)
-    $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG :=
-    $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG :=
-else
-    $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG := $(PRODUCT_AAPT_CONFIG)
-    $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := $(PRODUCT_AAPT_PREF_CONFIG)
-endif
-$(LOCAL_BUILT_MODULE): $(all_res_assets) $(jni_shared_libraries) $(full_android_manifest)
-	@echo "target Package: $(PRIVATE_MODULE) ($@)"
-	$(create-empty-package)
-	$(add-assets-to-package)
-ifneq ($(jni_shared_libraries),)
-	$(add-jni-shared-libs-to-package)
-endif
-ifneq ($(full_classes_jar),)
-	$(add-dex-to-package)
-endif
-	$(add-carried-java-resources)
-ifneq ($(extra_jar_args),)
-	$(add-java-resources-to-package)
-endif
-	$(sign-package)
-ifdef LOCAL_DEX_PREOPT
-	$(call dexpreopt-one-file,$(PRIVATE_DEX_PREOPT_IMAGE),$@,$(PRIVATE_DEX_LOCATION),$(PRIVATE_BUILT_ODEX))
-ifneq (nostripping,$(LOCAL_DEX_PREOPT))
-	$(call dexpreopt-remove-classes.dex,$@)
-endif
-endif
-	@# Alignment must happen after all other zip operations.
-	$(align-package)
-
-# Save information about this package
-PACKAGES.$(LOCAL_PACKAGE_NAME).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
-PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_FILES := $(all_resources)
-ifdef package_resource_overlays
-PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_OVERLAYS := $(package_resource_overlays)
+# check if primary arch is supported
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+ifeq ($(my_module_arch_supported),true)
+# primary arch is supported
+include $(BUILD_SYSTEM)/package_internal.mk
+else ifneq (,$(TARGET_2ND_ARCH))
+# check if secondary arch is supported
+LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX)
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+ifeq ($(my_module_arch_supported),true)
+# secondary arch is supported
+include $(BUILD_SYSTEM)/package_internal.mk
 endif
+endif # TARGET_2ND_ARCH
 
-PACKAGES := $(PACKAGES) $(LOCAL_PACKAGE_NAME)
-
-# Dist the files that can be bundled in system.img.
-# They include the jni shared libraries and the apk with jni libraries stripped.
-ifeq ($(LOCAL_DIST_BUNDLED_BINARIES),true)
-ifneq ($(filter $(LOCAL_PACKAGE_NAME),$(TARGET_BUILD_APPS)),)
-ifneq ($(strip $(jni_shared_libraries)),)
-dist_subdir := bundled_$(LOCAL_PACKAGE_NAME)
-$(foreach f, $(jni_shared_libraries), \
-  $(call dist-for-goals, apps_only, $(f):$(dist_subdir)/$(notdir $(f))))
-
-apk_jni_stripped := $(intermediates)/jni_stripped/package.apk
-$(apk_jni_stripped): PRIVATE_JNI_SHARED_LIBRARIES := $(notdir $(jni_shared_libraries))
-$(apk_jni_stripped) : $(LOCAL_BUILT_MODULE) | $(ZIPALIGN)
-	@rm -rf $(dir $@) && mkdir -p $(dir $@)
-	$(hide) cp $< $@
-	$(hide) zip -d $@ $(foreach f,$(PRIVATE_JNI_SHARED_LIBRARIES),\*/$(f))
-	$(call align-package)
-
-$(call dist-for-goals, apps_only, $(apk_jni_stripped):$(dist_subdir)/$(LOCAL_PACKAGE_NAME).apk)
-
-endif  # jni_shared_libraries
-endif  # apps_only build
-endif  # LOCAL_DIST_BUNDLED_BINARIES
-
-# Lint phony targets
-.PHONY: lint-$(LOCAL_PACKAGE_NAME)
-lint-$(LOCAL_PACKAGE_NAME): PRIVATE_PATH := $(LOCAL_PATH)
-lint-$(LOCAL_PACKAGE_NAME): PRIVATE_LINT_FLAGS := $(LOCAL_LINT_FLAGS)
-lint-$(LOCAL_PACKAGE_NAME) :
-	@echo lint $(PRIVATE_PATH)
-	$(LINT) $(PRIVATE_LINT_FLAGS) $(PRIVATE_PATH)
-
-lintall : lint-$(LOCAL_PACKAGE_NAME)
-
-endif # skip_definition
-
-# Reset internal variables.
-all_res_assets :=
-
+LOCAL_2ND_ARCH_VAR_PREFIX :=
 LOCAL_NO_2ND_ARCH_MODULE_SUFFIX :=
 
-LOCAL_2ND_ARCH_VAR_PREFIX :=
+my_module_arch_supported :=

File core/package_internal.mk

+#
+# Copyright (C) 2008 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+###########################################################
+## Standard rules for building an application package.
+##
+## Additional inputs from base_rules.make:
+## LOCAL_PACKAGE_NAME: The name of the package; the directory
+## will be called this.
+##
+## MODULE, MODULE_PATH, and MODULE_SUFFIX will
+## be set for you.
+###########################################################
+
+# If this makefile is being read from within an inheritance,
+# use the new values.
+skip_definition:=
+ifdef LOCAL_PACKAGE_OVERRIDES
+  package_overridden := $(call set-inherited-package-variables)
+  ifeq ($(strip $(package_overridden)),)
+    skip_definition := true
+  endif
+endif
+
+ifndef skip_definition
+
+LOCAL_PACKAGE_NAME := $(strip $(LOCAL_PACKAGE_NAME))
+ifeq ($(LOCAL_PACKAGE_NAME),)
+$(error $(LOCAL_PATH): Package modules must define LOCAL_PACKAGE_NAME)
+endif
+
+ifneq ($(strip $(LOCAL_MODULE_SUFFIX)),)
+$(error $(LOCAL_PATH): Package modules may not define LOCAL_MODULE_SUFFIX)
+endif
+LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
+
+ifneq ($(strip $(LOCAL_MODULE)),)
+$(error $(LOCAL_PATH): Package modules may not define LOCAL_MODULE)
+endif
+LOCAL_MODULE := $(LOCAL_PACKAGE_NAME)
+
+ifeq ($(strip $(LOCAL_MANIFEST_FILE)),)
+LOCAL_MANIFEST_FILE := AndroidManifest.xml
+endif
+
+# If you need to put the MANIFEST_FILE outside of LOCAL_PATH
+# you can use FULL_MANIFEST_FILE
+ifeq ($(strip $(LOCAL_FULL_MANIFEST_FILE)),)
+LOCAL_FULL_MANIFEST_FILE := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE)
+endif
+
+ifneq ($(strip $(LOCAL_MODULE_CLASS)),)
+$(error $(LOCAL_PATH): Package modules may not set LOCAL_MODULE_CLASS)
+endif
+LOCAL_MODULE_CLASS := APPS
+
+# Package LOCAL_MODULE_TAGS default to optional
+LOCAL_MODULE_TAGS := $(strip $(LOCAL_MODULE_TAGS))
+ifeq ($(LOCAL_MODULE_TAGS),)
+LOCAL_MODULE_TAGS := optional
+endif
+
+ifeq ($(filter tests, $(LOCAL_MODULE_TAGS)),)
+# Force localization check if it's not tagged as tests.
+LOCAL_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) -z
+endif
+
+ifeq (,$(LOCAL_ASSET_DIR))
+LOCAL_ASSET_DIR := $(LOCAL_PATH)/assets
+endif
+
+ifeq (,$(LOCAL_RESOURCE_DIR))
+  LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
+endif
+
+package_resource_overlays := $(strip \
+    $(wildcard $(foreach dir, $(PRODUCT_PACKAGE_OVERLAYS), \
+      $(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))) \
+    $(wildcard $(foreach dir, $(DEVICE_PACKAGE_OVERLAYS), \
+      $(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))))
+
+LOCAL_RESOURCE_DIR := $(package_resource_overlays) $(LOCAL_RESOURCE_DIR)
+
+all_assets := $(call find-subdir-assets,$(LOCAL_ASSET_DIR))
+all_assets := $(addprefix $(LOCAL_ASSET_DIR)/,$(patsubst assets/%,%,$(all_assets)))
+
+all_resources := $(strip \
+    $(foreach dir, $(LOCAL_RESOURCE_DIR), \
+      $(addprefix $(dir)/, \
+        $(patsubst res/%,%, \
+          $(call find-subdir-assets,$(dir)) \
+         ) \
+       ) \
+     ))
+
+all_res_assets := $(strip $(all_assets) $(all_resources))
+
+package_expected_intermediates_COMMON := $(call local-intermediates-dir,COMMON)
+# If no assets or resources were found, clear the directory variables so
+# we don't try to build them.
+ifeq (,$(all_assets))
+LOCAL_ASSET_DIR:=
+endif
+ifeq (,$(all_resources))
+LOCAL_RESOURCE_DIR:=
+R_file_stamp :=
+else
+# Make sure that R_file_stamp inherits the proper PRIVATE vars.
+# If R.stamp moves, be sure to update the framework makefile,
+# which has intimate knowledge of its location.
+R_file_stamp := $(package_expected_intermediates_COMMON)/src/R.stamp
+LOCAL_INTERMEDIATE_TARGETS += $(R_file_stamp)
+endif
+
+LOCAL_BUILT_MODULE_STEM := package.apk
+
+LOCAL_PROGUARD_ENABLED:=$(strip $(LOCAL_PROGUARD_ENABLED))
+ifndef LOCAL_PROGUARD_ENABLED
+ifneq ($(DISABLE_PROGUARD),true)
+    LOCAL_PROGUARD_ENABLED :=full
+endif
+endif
+ifeq ($(LOCAL_PROGUARD_ENABLED),disabled)
+    # the package explicitly request to disable proguard.
+    LOCAL_PROGUARD_ENABLED :=
+endif
+proguard_options_file :=
+ifneq ($(LOCAL_PROGUARD_ENABLED),custom)
+ifneq ($(all_resources),)
+    proguard_options_file := $(package_expected_intermediates_COMMON)/proguard_options
+endif # all_resources
+endif # !custom
+LOCAL_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_PROGUARD_FLAGS)
+
+ifeq (true,$(EMMA_INSTRUMENT))
+ifndef LOCAL_EMMA_INSTRUMENT
+# No emma for test apks.
+ifeq (,$(filer tests,$(LOCAL_MODULE_TAGS))$(LOCAL_INSTRUMENTATION_FOR))
+LOCAL_EMMA_INSTRUMENT := true
+endif # No test apk
+endif # LOCAL_EMMA_INSTRUMENT is not set
+else
+LOCAL_EMMA_INSTRUMENT := false
+endif # EMMA_INSTRUMENT is true
+
+ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
+ifeq (true,$(EMMA_INSTRUMENT_STATIC))
+LOCAL_STATIC_JAVA_LIBRARIES += emma
+else
+ifdef LOCAL_SDK_VERSION
+ifdef TARGET_BUILD_APPS
+# In unbundled build merge the emma library into the apk.
+LOCAL_STATIC_JAVA_LIBRARIES += emma
+else
+# If build against the SDK in full build, core.jar is not used,
+# we have to use prebiult emma.jar to make Proguard happy;
+# Otherwise emma classes are included in core.jar.
+LOCAL_PROGUARD_FLAGS += -libraryjars $(EMMA_JAR)
+endif # full build
+endif # LOCAL_SDK_VERSION
+endif # EMMA_INSTRUMENT_STATIC
+endif # LOCAL_EMMA_INSTRUMENT
+
+rs_compatibility_jni_libs :=
+
+#################################
+include $(BUILD_SYSTEM)/java.mk
+#################################
+
+LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION))
+ifeq ($(LOCAL_SDK_RES_VERSION),)
+  LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION)
+endif
+
+full_android_manifest := $(LOCAL_FULL_MANIFEST_FILE)
+$(LOCAL_INTERMEDIATE_TARGETS): \
+    PRIVATE_ANDROID_MANIFEST := $(full_android_manifest)
+ifneq (,$(filter-out current, $(LOCAL_SDK_VERSION)))
+$(LOCAL_INTERMEDIATE_TARGETS): \
+    PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION)
+else
+$(LOCAL_INTERMEDIATE_TARGETS): \
+    PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK)
+endif
+
+ifneq ($(all_resources),)
+
+# Since we don't know where the real R.java file is going to end up,
+# we need to use another file to stand in its place.  We'll just
+# copy the generated file to src/R.stamp, which means it will
+# have the same contents and timestamp as the actual file.
+#
+# At the same time, this will copy the R.java file to a central
+# 'R' directory to make it easier to add the files to an IDE.
+#
+#TODO: use PRIVATE_SOURCE_INTERMEDIATES_DIR instead of
+#      $(intermediates.COMMON)/src
+ifneq ($(package_expected_intermediates_COMMON),$(intermediates.COMMON))
+  $(error $(LOCAL_MODULE): internal error: expected intermediates.COMMON "$(package_expected_intermediates_COMMON)" != intermediates.COMMON "$(intermediates.COMMON)")
+endif
+
+$(R_file_stamp): PRIVATE_RESOURCE_PUBLICS_OUTPUT := \
+			$(intermediates.COMMON)/public_resources.xml
+$(R_file_stamp): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file)
+$(R_file_stamp): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT) | $(ACP)
+	@echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)"
+	@rm -f $@
+	$(create-resource-java-files)
+	$(hide) for GENERATED_MANIFEST_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \
+					-name Manifest.java 2> /dev/null`; do \
+		dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_MANIFEST_FILE`; \
+		mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \
+		$(ACP) -fp $$GENERATED_MANIFEST_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \
+	done;
+	$(hide) for GENERATED_R_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \
+					-name R.java 2> /dev/null`; do \
+		dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_R_FILE`; \
+		mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \
+		$(ACP) -fp $$GENERATED_R_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir \
+			|| exit 31; \
+		$(ACP) -fp $$GENERATED_R_FILE $@ || exit 32; \
+	done; \
+
+$(proguard_options_file): $(R_file_stamp)
+
+ifdef LOCAL_EXPORT_PACKAGE_RESOURCES
+# Put this module's resources into a PRODUCT-agnositc package that
+# other packages can use to build their own PRODUCT-agnostic R.java (etc.)
+# files.
+resource_export_package := $(intermediates.COMMON)/package-export.apk
+$(R_file_stamp): $(resource_export_package)
+
+# add-assets-to-package looks at PRODUCT_AAPT_CONFIG, but this target
+# can't know anything about PRODUCT.  Clear it out just for this target.
+$(resource_export_package): PRIVATE_PRODUCT_AAPT_CONFIG :=
+$(resource_export_package): PRIVATE_PRODUCT_AAPT_PREF_CONFIG :=
+$(resource_export_package): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT)
+	@echo "target Export Resources: $(PRIVATE_MODULE) ($@)"
+	$(create-empty-package)
+	$(add-assets-to-package)
+endif
+
+# Other modules should depend on the BUILT module if
+# they want to use this module's R.java file.
+$(LOCAL_BUILT_MODULE): $(R_file_stamp)
+
+ifneq ($(full_classes_jar),)
+# If full_classes_jar is non-empty, we're building sources.
+# If we're building sources, the initial javac step (which
+# produces full_classes_compiled_jar) needs to ensure the
+# R.java and Manifest.java files have been generated first.
+$(full_classes_compiled_jar): $(R_file_stamp)
+endif
+
+endif  # all_resources
+
+ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
+# We need to explicitly clear this var so that we don't
+# inherit the value from whomever caused us to be built.
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_INCLUDES :=
+else
+# Most packages should link against the resources defined by framework-res.
+# Even if they don't have their own resources, they may use framework
+# resources.
+ifneq ($(filter-out current,$(LOCAL_SDK_RES_VERSION))$(if $(TARGET_BUILD_APPS),$(filter current,$(LOCAL_SDK_RES_VERSION))),)
+# for released sdk versions, the platform resources were built into android.jar.
+framework_res_package_export := \
+    $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_RES_VERSION)/android.jar
+framework_res_package_export_deps := $(framework_res_package_export)
+else # LOCAL_SDK_RES_VERSION
+framework_res_package_export := \
+    $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
+# We can't depend directly on the export.apk file; it won't get its
+# PRIVATE_ vars set up correctly if we do.  Instead, depend on the
+# corresponding R.stamp file, which lists the export.apk as a dependency.
+framework_res_package_export_deps := \
+    $(dir $(framework_res_package_export))src/R.stamp
+endif # LOCAL_SDK_RES_VERSION
+$(R_file_stamp): $(framework_res_package_export_deps)
+$(LOCAL_INTERMEDIATE_TARGETS): \
+    PRIVATE_AAPT_INCLUDES := $(framework_res_package_export)
+endif # LOCAL_NO_STANDARD_LIBRARIES
+
+ifneq ($(full_classes_jar),)
+$(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex)
+$(LOCAL_BUILT_MODULE): $(built_dex)
+endif # full_classes_jar
+
+
+# Get the list of jni libraries to be included in the apk file.
+
+so_suffix := $($(my_prefix)SHLIB_SUFFIX)
+
+jni_shared_libraries := \
+    $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
+      $(addsuffix $(so_suffix), \
+        $(LOCAL_JNI_SHARED_LIBRARIES)))
+
+# Include RS dynamically-generated libraries as well
+# Keep this ifneq, as the += otherwise adds spaces that need to be stripped.
+ifneq ($(rs_compatibility_jni_libs),)
+jni_shared_libraries += $(rs_compatibility_jni_libs)
+endif
+
+# App explicitly requires the prebuilt NDK libstlport_shared.so.
+# libstlport_shared.so should never go to the system image.
+# Instead it should be packaged into the apk.
+ifeq (stlport_shared,$(LOCAL_NDK_STL_VARIANT))
+ifndef LOCAL_SDK_VERSION
+$(error LOCAL_SDK_VERSION has to be defined together with LOCAL_NDK_STL_VARIANT, \
+    LOCAL_PACKAGE_NAME=$(LOCAL_PACKAGE_NAME))
+endif
+jni_shared_libraries += \
+    $(HISTORICAL_NDK_VERSIONS_ROOT)/current/sources/cxx-stl/stlport/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libstlport_shared.so
+endif
+
+# Set the abi directory used by the local JNI shared libraries.
+# (Doesn't change how the local shared libraries are compiled, just
+# sets where they are stored in the apk.)
+
+ifeq ($(LOCAL_JNI_SHARED_LIBRARIES_ABI),)
+    jni_shared_libraries_abi := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)
+else
+    jni_shared_libraries_abi := $(LOCAL_JNI_SHARED_LIBRARIES_ABI)
+endif
+
+# Pick a key to sign the package with.  If this package hasn't specified
+# an explicit certificate, use the default.
+# Secure release builds will have their packages signed after the fact,
+# so it's ok for these private keys to be in the clear.
+ifeq ($(LOCAL_CERTIFICATE),)
+    LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
+endif
+
+ifeq ($(LOCAL_CERTIFICATE),EXTERNAL)
+  # The special value "EXTERNAL" means that we will sign it with the
+  # default devkey, apply predexopt, but then expect the final .apk
+  # (after dexopting) to be signed by an outside tool.
+  LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
+  PACKAGES.$(LOCAL_PACKAGE_NAME).EXTERNAL_KEY := 1
+endif
+
+# If this is not an absolute certificate, assign it to a generic one.
+ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./)
+    LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE)
+endif
+private_key := $(LOCAL_CERTIFICATE).pk8
+certificate := $(LOCAL_CERTIFICATE).x509.pem
+
+$(LOCAL_BUILT_MODULE): $(private_key) $(certificate) $(SIGNAPK_JAR)
+$(LOCAL_BUILT_MODULE): PRIVATE_PRIVATE_KEY := $(private_key)
+$(LOCAL_BUILT_MODULE): PRIVATE_CERTIFICATE := $(certificate)
+
+PACKAGES.$(LOCAL_PACKAGE_NAME).PRIVATE_KEY := $(private_key)
+PACKAGES.$(LOCAL_PACKAGE_NAME).CERTIFICATE := $(certificate)
+
+$(LOCAL_BUILT_MODULE): PRIVATE_ADDITIONAL_CERTIFICATES := $(foreach c,\
+    $(LOCAL_ADDITIONAL_CERTIFICATES), $(c).x509.pem $(c).pk8)
+
+# Define the rule to build the actual package.
+$(LOCAL_BUILT_MODULE): $(AAPT) | $(ZIPALIGN)
+ifdef LOCAL_DEX_PREOPT
+$(LOCAL_BUILT_MODULE): PRIVATE_DEX_LOCATION := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
+$(LOCAL_BUILT_MODULE): PRIVATE_BUILT_ODEX := $(built_odex)
+$(LOCAL_BUILT_MODULE): PRIVATE_DEX_PREOPT_IMAGE := $(LOCAL_DEX_PREOPT_IMAGE)
+# Make sure the boot jars get dexpreopt-ed first
+$(LOCAL_BUILT_MODULE) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT)
+$(LOCAL_BUILT_MODULE) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS)
+$(LOCAL_BUILT_MODULE) : $(LOCAL_DEX_PREOPT_IMAGE)
+
+# built_odex is byproduct of LOCAL_BUILT_MODULE without its own build recipe.
+$(built_odex) : $(LOCAL_BUILT_MODULE)
+endif
+$(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES := $(jni_shared_libraries)
+$(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES_ABI := $(jni_shared_libraries_abi)
+ifneq ($(TARGET_BUILD_APPS),)
+    # Include all resources for unbundled apps.
+    LOCAL_AAPT_INCLUDE_ALL_RESOURCES := true
+endif
+ifeq ($(LOCAL_AAPT_INCLUDE_ALL_RESOURCES),true)
+    $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG :=
+    $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG :=
+else
+    $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG := $(PRODUCT_AAPT_CONFIG)
+    $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := $(PRODUCT_AAPT_PREF_CONFIG)
+endif
+$(LOCAL_BUILT_MODULE): $(all_res_assets) $(jni_shared_libraries) $(full_android_manifest)
+	@echo "target Package: $(PRIVATE_MODULE) ($@)"
+	$(create-empty-package)
+	$(add-assets-to-package)
+ifneq ($(jni_shared_libraries),)
+	$(add-jni-shared-libs-to-package)
+endif
+ifneq ($(full_classes_jar),)
+	$(add-dex-to-package)
+endif
+	$(add-carried-java-resources)
+ifneq ($(extra_jar_args),)
+	$(add-java-resources-to-package)
+endif
+	$(sign-package)
+ifdef LOCAL_DEX_PREOPT
+	$(call dexpreopt-one-file,$(PRIVATE_DEX_PREOPT_IMAGE),$@,$(PRIVATE_DEX_LOCATION),$(PRIVATE_BUILT_ODEX))
+ifneq (nostripping,$(LOCAL_DEX_PREOPT))
+	$(call dexpreopt-remove-classes.dex,$@)
+endif
+endif
+	@# Alignment must happen after all other zip operations.
+	$(align-package)
+
+# Save information about this package
+PACKAGES.$(LOCAL_PACKAGE_NAME).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
+PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_FILES := $(all_resources)
+ifdef package_resource_overlays
+PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_OVERLAYS := $(package_resource_overlays)
+endif
+
+PACKAGES := $(PACKAGES) $(LOCAL_PACKAGE_NAME)
+
+# Dist the files that can be bundled in system.img.
+# They include the jni shared libraries and the apk with jni libraries stripped.
+ifeq ($(LOCAL_DIST_BUNDLED_BINARIES),true)
+ifneq ($(filter $(LOCAL_PACKAGE_NAME),$(TARGET_BUILD_APPS)),)
+ifneq ($(strip $(jni_shared_libraries)),)
+dist_subdir := bundled_$(LOCAL_PACKAGE_NAME)
+$(foreach f, $(jni_shared_libraries), \
+  $(call dist-for-goals, apps_only, $(f):$(dist_subdir)/$(notdir $(f))))
+
+apk_jni_stripped := $(intermediates)/jni_stripped/package.apk
+$(apk_jni_stripped): PRIVATE_JNI_SHARED_LIBRARIES := $(notdir $(jni_shared_libraries))
+$(apk_jni_stripped) : $(LOCAL_BUILT_MODULE) | $(ZIPALIGN)
+	@rm -rf $(dir $@) && mkdir -p $(dir $@)
+	$(hide) cp $< $@
+	$(hide) zip -d $@ $(foreach f,$(PRIVATE_JNI_SHARED_LIBRARIES),\*/$(f))
+	$(call align-package)
+
+$(call dist-for-goals, apps_only, $(apk_jni_stripped):$(dist_subdir)/$(LOCAL_PACKAGE_NAME).apk)
+
+endif  # jni_shared_libraries
+endif  # apps_only build
+endif  # LOCAL_DIST_BUNDLED_BINARIES
+
+# Lint phony targets
+.PHONY: lint-$(LOCAL_PACKAGE_NAME)
+lint-$(LOCAL_PACKAGE_NAME): PRIVATE_PATH := $(LOCAL_PATH)
+lint-$(LOCAL_PACKAGE_NAME): PRIVATE_LINT_FLAGS := $(LOCAL_LINT_FLAGS)
+lint-$(LOCAL_PACKAGE_NAME) :
+	@echo lint $(PRIVATE_PATH)
+	$(LINT) $(PRIVATE_LINT_FLAGS) $(PRIVATE_PATH)
+
+lintall : lint-$(LOCAL_PACKAGE_NAME)
+
+endif # skip_definition
+
+# Reset internal variables.
+all_res_assets :=

File core/prebuilt.mk

 ##
 ###########################################################
 
-ifneq ($(LOCAL_PREBUILT_LIBS),)
-$(error dont use LOCAL_PREBUILT_LIBS anymore LOCAL_PATH=$(LOCAL_PATH))
-endif
-ifneq ($(LOCAL_PREBUILT_EXECUTABLES),)
-$(error dont use LOCAL_PREBUILT_EXECUTABLES anymore LOCAL_PATH=$(LOCAL_PATH))
-endif
-ifneq ($(LOCAL_PREBUILT_JAVA_LIBRARIES),)
-$(error dont use LOCAL_PREBUILT_JAVA_LIBRARIES anymore LOCAL_PATH=$(LOCAL_PATH))
-endif
-
-ifneq ($(TARGET_IS_64_BIT)|$(LOCAL_32_BIT_ONLY),true|true)
-# Build for TARGET_ARCH
-LOCAL_2ND_ARCH_VAR_PREFIX :=
-else
-# Build for TARGET_2ND_ARCH
-LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX)
-endif
-
-
-# Not much sense to check build prebuilts
-LOCAL_DONT_CHECK_MODULE := true
-
-ifdef LOCAL_PREBUILT_MODULE_FILE
-my_prebuilt_src_file := $(LOCAL_PREBUILT_MODULE_FILE)
-else
-my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES)
-endif
-
 ifdef LOCAL_IS_HOST_MODULE
-  my_prefix := HOST_
-else
-  my_prefix := TARGET_
-endif
-ifeq (SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS))
-  # Put the built targets of all shared libraries in a common directory
-  # to simplify the link line.
-  OVERRIDE_BUILT_MODULE_PATH := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)
-endif
-
-ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
-  prebuilt_module_is_a_library := true
-else
-  prebuilt_module_is_a_library :=
-endif
-
-# Don't install static libraries by default.
-ifndef LOCAL_UNINSTALLABLE_MODULE
-ifeq (STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS))
-  LOCAL_UNINSTALLABLE_MODULE := true
-endif
-endif
-
-ifeq ($(LOCAL_STRIP_MODULE),true)
-  ifdef LOCAL_IS_HOST_MODULE
-    $(error Cannot strip host module LOCAL_PATH=$(LOCAL_PATH))
-  endif
-  ifeq ($(filter SHARED_LIBRARIES EXECUTABLES,$(LOCAL_MODULE_CLASS)),)
-    $(error Can strip only shared libraries or executables LOCAL_PATH=$(LOCAL_PATH))
-  endif
-  ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
-    $(error Cannot strip scripts LOCAL_PATH=$(LOCAL_PATH))
-  endif
-  include $(BUILD_SYSTEM)/dynamic_binary.mk
-  built_module := $(linked_module)
-else  # LOCAL_STRIP_MODULE not true
-  include $(BUILD_SYSTEM)/base_rules.mk
-  built_module := $(LOCAL_BUILT_MODULE)
-
-ifdef prebuilt_module_is_a_library
-export_includes := $(intermediates)/export_includes
-$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
-$(export_includes) : $(LOCAL_MODULE_MAKEFILE)
-	@echo Export includes file: $< -- $@
-	$(hide) mkdir -p $(dir $@) && rm -f $@
-ifdef LOCAL_EXPORT_C_INCLUDE_DIRS
-	$(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
-	        echo "-I $$d" >> $@; \
-	        done
-else
-	$(hide) touch $@
-endif
-
-$(LOCAL_BUILT_MODULE) : | $(intermediates)/export_includes
-endif  # prebuilt_module_is_a_library
-
-# The real dependency will be added after all Android.mks are loaded and the install paths
-# of the shared libraries are determined.
-ifdef LOCAL_INSTALLED_MODULE
-ifdef LOCAL_SHARED_LIBRARIES
-$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += $(LOCAL_MODULE):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(LOCAL_SHARED_LIBRARIES))
-
-# We also need the LOCAL_BUILT_MODULE dependency,
-# since we use -rpath-link which points to the built module's path.
-built_shared_libraries := \
-    $(addprefix $($(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
-    $(addsuffix $($(my_prefix)SHLIB_SUFFIX), \
-        $(LOCAL_SHARED_LIBRARIES)))
-$(LOCAL_BUILT_MODULE) : $(built_shared_libraries)
-endif
-endif
-
-endif  # LOCAL_STRIP_MODULE not true
-
-PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
-
-ifeq ($(LOCAL_CERTIFICATE),EXTERNAL)
-  # The magic string "EXTERNAL" means this package will be signed with
-  # the default dev key throughout the build process, but we expect
-  # the final package to be signed with a different key.
-  #
-  # This can be used for packages where we don't have access to the
-  # keys, but want the package to be predexopt'ed.
-  LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
-  PACKAGES.$(LOCAL_MODULE).EXTERNAL_KEY := 1
-
-  $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
-  $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
-endif
-ifeq ($(LOCAL_CERTIFICATE),)
-  ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
-    # It is now a build error to add a prebuilt .apk without
-    # specifying a key for it.
-    $(error No LOCAL_CERTIFICATE specified for prebuilt "$(my_prebuilt_src_file)")
-  endif
-else ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
-  # The magic string "PRESIGNED" means this package is already checked
-  # signed with its release key.
-  #
-  # By setting .CERTIFICATE but not .PRIVATE_KEY, this package will be
-  # mentioned in apkcerts.txt (with certificate set to "PRESIGNED")
-  # but the dexpreopt process will not try to re-sign the app.
-  PACKAGES.$(LOCAL_MODULE).CERTIFICATE := PRESIGNED
-  PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
-else
-  # If this is not an absolute certificate, assign it to a generic one.
-  ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./)
-      LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE)
-  endif
-
-  PACKAGES.$(LOCAL_MODULE).PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
-  PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
-  PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
-
-  $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
-  $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
-endif
-
-ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
-
-# Disable dex-preopt of prebuilts to save space
-LOCAL_DEX_PREOPT := false
-
-#######################################
-# defines built_odex along with rule to install odex
-include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
-#######################################
-ifdef LOCAL_DEX_PREOPT
-$(built_module): PRIVATE_DEX_PREOPT_IMAGE := $(LOCAL_DEX_PREOPT_IMAGE)
-$(built_module): PRIVATE_DEX_LOCATION := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
-$(built_module): PRIVATE_BUILT_ODEX := $(built_odex)
-# Make sure the boot jars get dexpreopt-ed first
-$(built_module) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT)
-$(built_module) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS)
-(built_module) : $(LOCAL_DEX_PREOPT_IMAGE)
-# built_odex is byproduct of LOCAL_BUILT_MODULE without its own build recipe.
-$(built_odex) : $(LOCAL_BUILT_MODULE)
-endif # LOCAL_DEX_PREOPT
-# Sign and align non-presigned .apks.
-$(built_module) : $(my_prebuilt_src_file) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR)
-	$(transform-prebuilt-to-target)
-ifneq ($(LOCAL_CERTIFICATE),PRESIGNED)
-	$(sign-package)
-endif
-ifdef LOCAL_DEX_PREOPT
-	$(call dexpreopt-one-file,$(PRIVATE_DEX_PREOPT_IMAGE),$@,$(PRIVATE_DEX_LOCATION),$(PRIVATE_BUILT_ODEX))
-endif
-	$(align-package)
-
-else # LOCAL_MODULE_CLASS != APPS
-ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
-$(built_module) : $(my_prebuilt_src_file)
-	$(transform-prebuilt-to-target-strip-comments)
-else
-$(built_module) : $(my_prebuilt_src_file) | $(ACP)
-	$(transform-prebuilt-to-target)
-ifneq ($(prebuilt_module_is_a_library),)
-  ifneq ($(LOCAL_IS_HOST_MODULE),)
-	$(transform-host-ranlib-copy-hack)
-  else
-	$(transform-ranlib-copy-hack)
-  endif
-endif
+include $(BUILD_SYSTEM)/prebuilt_internal.mk
+else #!LOCAL_IS_HOST_MODULE
+# check if primary arch is supported
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+ifeq ($(my_module_arch_supported),true)
+# primary arch is supported
+include $(BUILD_SYSTEM)/prebuilt_internal.mk
+else ifneq (,$(TARGET_2ND_ARCH))
+# check if secondary arch is supported
+LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX)
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+ifeq ($(my_module_arch_supported),true)
+# secondary arch is supported
+include $(BUILD_SYSTEM)/prebuilt_internal.mk
 endif
-endif # LOCAL_MODULE_CLASS != APPS
-
-ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
-# for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir,
-# while the deps should be in the common dir, so we make a copy in the common dir.
-# For nonstatic library, $(common_javalib_jar) is the dependency file,
-# while $(common_classes_jar) is used to link.
-common_classes_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),,COMMON)/classes.jar
-common_javalib_jar := $(dir $(common_classes_jar))javalib.jar
-
-$(common_classes_jar) : $(my_prebuilt_src_file) | $(ACP)
-	$(transform-prebuilt-to-target)
-
-$(common_javalib_jar) : $(common_classes_jar) | $(ACP)
-	$(transform-prebuilt-to-target)
-
-# make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE)
-$(built_module) : $(common_javalib_jar)
-endif # TARGET JAVA_LIBRARIES
-
-$(built_module) : $(LOCAL_ADDITIONAL_DEPENDENCIES)
-
-my_prebuilt_src_file :=
+endif # TARGET_2ND_ARCH
+endif # !LOCAL_IS_HOST_MODULE
 
 LOCAL_2ND_ARCH_VAR_PREFIX :=
+
+my_module_arch_supported :=

File core/prebuilt_internal.mk

+###########################################################
+## Standard rules for copying files that are prebuilt
+##
+## Additional inputs from base_rules.make:
+## None.
+##
+###########################################################
+
+ifneq ($(LOCAL_PREBUILT_LIBS),)
+$(error dont use LOCAL_PREBUILT_LIBS anymore LOCAL_PATH=$(LOCAL_PATH))
+endif
+ifneq ($(LOCAL_PREBUILT_EXECUTABLES),)
+$(error dont use LOCAL_PREBUILT_EXECUTABLES anymore LOCAL_PATH=$(LOCAL_PATH))
+endif
+ifneq ($(LOCAL_PREBUILT_JAVA_LIBRARIES),)
+$(error dont use LOCAL_PREBUILT_JAVA_LIBRARIES anymore LOCAL_PATH=$(LOCAL_PATH))
+endif
+
+# Not much sense to check build prebuilts
+LOCAL_DONT_CHECK_MODULE := true
+
+ifdef LOCAL_PREBUILT_MODULE_FILE
+my_prebuilt_src_file := $(LOCAL_PREBUILT_MODULE_FILE)
+else
+my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES)
+endif
+
+ifdef LOCAL_IS_HOST_MODULE
+  my_prefix := HOST_
+else
+  my_prefix := TARGET_
+endif
+ifeq (SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS))
+  # Put the built targets of all shared libraries in a common directory
+  # to simplify the link line.
+  OVERRIDE_BUILT_MODULE_PATH := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)
+endif
+
+ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
+  prebuilt_module_is_a_library := true
+else
+  prebuilt_module_is_a_library :=
+endif
+
+# Don't install static libraries by default.
+ifndef LOCAL_UNINSTALLABLE_MODULE
+ifeq (STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS))
+  LOCAL_UNINSTALLABLE_MODULE := true
+endif
+endif
+
+ifeq ($(LOCAL_STRIP_MODULE),true)
+  ifdef LOCAL_IS_HOST_MODULE
+    $(error Cannot strip host module LOCAL_PATH=$(LOCAL_PATH))
+  endif
+  ifeq ($(filter SHARED_LIBRARIES EXECUTABLES,$(LOCAL_MODULE_CLASS)),)
+    $(error Can strip only shared libraries or executables LOCAL_PATH=$(LOCAL_PATH))
+  endif
+  ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
+    $(error Cannot strip scripts LOCAL_PATH=$(LOCAL_PATH))
+  endif
+  include $(BUILD_SYSTEM)/dynamic_binary.mk
+  built_module := $(linked_module)
+else  # LOCAL_STRIP_MODULE not true
+  include $(BUILD_SYSTEM)/base_rules.mk
+  built_module := $(LOCAL_BUILT_MODULE)
+
+ifdef prebuilt_module_is_a_library
+export_includes := $(intermediates)/export_includes
+$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
+$(export_includes) : $(LOCAL_MODULE_MAKEFILE)
+	@echo Export includes file: $< -- $@
+	$(hide) mkdir -p $(dir $@) && rm -f $@
+ifdef LOCAL_EXPORT_C_INCLUDE_DIRS
+	$(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
+	        echo "-I $$d" >> $@; \
+	        done
+else
+	$(hide) touch $@
+endif
+
+$(LOCAL_BUILT_MODULE) : | $(intermediates)/export_includes
+endif  # prebuilt_module_is_a_library
+
+# The real dependency will be added after all Android.mks are loaded and the install paths
+# of the shared libraries are determined.
+ifdef LOCAL_INSTALLED_MODULE
+ifdef LOCAL_SHARED_LIBRARIES
+$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += $(LOCAL_MODULE):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(LOCAL_SHARED_LIBRARIES))
+
+# We also need the LOCAL_BUILT_MODULE dependency,
+# since we use -rpath-link which points to the built module's path.
+built_shared_libraries := \
+    $(addprefix $($(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
+    $(addsuffix $($(my_prefix)SHLIB_SUFFIX), \
+        $(LOCAL_SHARED_LIBRARIES)))
+$(LOCAL_BUILT_MODULE) : $(built_shared_libraries)
+endif
+endif
+
+endif  # LOCAL_STRIP_MODULE not true
+
+PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
+
+ifeq ($(LOCAL_CERTIFICATE),EXTERNAL)
+  # The magic string "EXTERNAL" means this package will be signed with
+  # the default dev key throughout the build process, but we expect
+  # the final package to be signed with a different key.
+  #
+  # This can be used for packages where we don't have access to the
+  # keys, but want the package to be predexopt'ed.
+  LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
+  PACKAGES.$(LOCAL_MODULE).EXTERNAL_KEY := 1
+
+  $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
+  $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
+endif
+ifeq ($(LOCAL_CERTIFICATE),)
+  ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
+    # It is now a build error to add a prebuilt .apk without
+    # specifying a key for it.
+    $(error No LOCAL_CERTIFICATE specified for prebuilt "$(my_prebuilt_src_file)")
+  endif
+else ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
+  # The magic string "PRESIGNED" means this package is already checked
+  # signed with its release key.
+  #
+  # By setting .CERTIFICATE but not .PRIVATE_KEY, this package will be
+  # mentioned in apkcerts.txt (with certificate set to "PRESIGNED")
+  # but the dexpreopt process will not try to re-sign the app.
+  PACKAGES.$(LOCAL_MODULE).CERTIFICATE := PRESIGNED
+  PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
+else
+  # If this is not an absolute certificate, assign it to a generic one.
+  ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./)
+      LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE)
+  endif
+
+  PACKAGES.$(LOCAL_MODULE).PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
+  PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
+  PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
+
+  $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
+  $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
+endif
+
+ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
+
+# Disable dex-preopt of prebuilts to save space
+LOCAL_DEX_PREOPT := false
+
+#######################################
+# defines built_odex along with rule to install odex
+include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
+#######################################
+ifdef LOCAL_DEX_PREOPT
+$(built_module): PRIVATE_DEX_PREOPT_IMAGE := $(LOCAL_DEX_PREOPT_IMAGE)
+$(built_module): PRIVATE_DEX_LOCATION := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
+$(built_module): PRIVATE_BUILT_ODEX := $(built_odex)
+# Make sure the boot jars get dexpreopt-ed first
+$(built_module) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT)
+$(built_module) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS)
+(built_module) : $(LOCAL_DEX_PREOPT_IMAGE)
+# built_odex is byproduct of LOCAL_BUILT_MODULE without its own build recipe.
+$(built_odex) : $(LOCAL_BUILT_MODULE)
+endif # LOCAL_DEX_PREOPT
+# Sign and align non-presigned .apks.
+$(built_module) : $(my_prebuilt_src_file) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR)
+	$(transform-prebuilt-to-target)
+ifneq ($(LOCAL_CERTIFICATE),PRESIGNED)
+	$(sign-package)
+endif
+ifdef LOCAL_DEX_PREOPT
+	$(call dexpreopt-one-file,$(PRIVATE_DEX_PREOPT_IMAGE),$@,$(PRIVATE_DEX_LOCATION),$(PRIVATE_BUILT_ODEX))
+endif
+	$(align-package)
+
+else # LOCAL_MODULE_CLASS != APPS
+ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
+$(built_module) : $(my_prebuilt_src_file)
+	$(transform-prebuilt-to-target-strip-comments)
+else
+$(built_module) : $(my_prebuilt_src_file) | $(ACP)
+	$(transform-prebuilt-to-target)
+ifneq ($(prebuilt_module_is_a_library),)
+  ifneq ($(LOCAL_IS_HOST_MODULE),)
+	$(transform-host-ranlib-copy-hack)
+  else
+	$(transform-ranlib-copy-hack)
+  endif
+endif
+endif
+endif # LOCAL_MODULE_CLASS != APPS
+
+ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
+# for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir,
+# while the deps should be in the common dir, so we make a copy in the common dir.
+# For nonstatic library, $(common_javalib_jar) is the dependency file,
+# while $(common_classes_jar) is used to link.
+common_classes_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),,COMMON)/classes.jar
+common_javalib_jar := $(dir $(common_classes_jar))javalib.jar
+
+$(common_classes_jar) : $(my_prebuilt_src_file) | $(ACP)
+	$(transform-prebuilt-to-target)
+
+$(common_javalib_jar) : $(common_classes_jar) | $(ACP)
+	$(transform-prebuilt-to-target)
+
+# make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE)
+$(built_module) : $(common_javalib_jar)
+endif # TARGET JAVA_LIBRARIES
+
+$(built_module) : $(LOCAL_ADDITIONAL_DEPENDENCIES)
+
+my_prebuilt_src_file :=
+
+LOCAL_2ND_ARCH_VAR_PREFIX :=

File core/shared_library.mk

 endif
 endif
 
-ifneq ($(TARGET_IS_64_BIT)|$(LOCAL_32_BIT_ONLY),true|true)
-# Build for TARGET_ARCH
 LOCAL_2ND_ARCH_VAR_PREFIX :=
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+
+ifeq ($(my_module_arch_supported),true)
 include $(BUILD_SYSTEM)/shared_library_internal.mk
 endif
 
 ifdef TARGET_2ND_ARCH
-ifneq ($(LOCAL_NO_2ND_ARCH),true)
+
+LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX)
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+
+ifeq ($(my_module_arch_supported),true)
 # Build for TARGET_2ND_ARCH
 OVERRIDE_BUILT_MODULE_PATH :=
 LOCAL_BUILT_MODULE :=
 LOCAL_INSTALLED_MODULE_STEM :=
 LOCAL_INTERMEDIATE_TARGETS :=
 
-LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX)
 include $(BUILD_SYSTEM)/shared_library_internal.mk
+
+endif
+
 LOCAL_2ND_ARCH_VAR_PREFIX :=
 
-endif # LOCAL_NO_2ND_ARCH
 endif # TARGET_2ND_ARCH
+
+my_module_arch_supported :=

File core/static_library.mk

-ifneq ($(TARGET_IS_64_BIT)|$(LOCAL_32_BIT_ONLY),true|true)
-# Build for TARGET_ARCH
 LOCAL_2ND_ARCH_VAR_PREFIX :=
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+
+ifeq ($(my_module_arch_supported),true)
 include $(BUILD_SYSTEM)/static_library_internal.mk
 endif
 
 ifdef TARGET_2ND_ARCH
-ifneq ($(LOCAL_NO_2ND_ARCH),true)
+
+LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX)
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+
+ifeq ($(my_module_arch_supported),true)
 # Build for TARGET_2ND_ARCH
 OVERRIDE_BUILT_MODULE_PATH :=
 LOCAL_BUILT_MODULE :=
 LOCAL_INSTALLED_MODULE_STEM :=
 LOCAL_INTERMEDIATE_TARGETS :=
 
-LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX)
 include $(BUILD_SYSTEM)/static_library_internal.mk
+
+endif
+
 LOCAL_2ND_ARCH_VAR_PREFIX :=
 
-endif # LOCAL_NO_2ND_ARCH
 endif # TARGET_2ND_ARCH
+
+my_module_arch_supported :=

File core/tasks/cts.mk

 VMTESTSTF_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,vm-tests-tf,HOST)
 VMTESTSTF_JAR := $(VMTESTSTF_INTERMEDIATES)/android.core.vm-tests-tf.jar
 
+# The list of test packages that core-tests (libcore/Android.mk)
+# is split into.
 CTS_CORE_CASE_LIST := \
 	android.core.tests.libcore.package.dalvik \
 	android.core.tests.libcore.package.com \
 	android.core.tests.libcore.package.tests \
 	android.core.tests.libcore.package.org \
 	android.core.tests.libcore.package.libcore \
+	android.core.tests.libcore.package.jsr166 \
+	android.core.tests.libcore.package.harmony_annotation \
+	android.core.tests.libcore.package.harmony_java_io \
+	android.core.tests.libcore.package.harmony_java_lang \
+	android.core.tests.libcore.package.harmony_java_math \
+	android.core.tests.libcore.package.harmony_java_net \
+	android.core.tests.libcore.package.harmony_java_nio \
+	android.core.tests.libcore.package.harmony_java_text \
+	android.core.tests.libcore.package.harmony_java_util \
+	android.core.tests.libcore.package.harmony_javax_security \
 	android.core.tests.runner
 
+# The list of test packages that apache-harmony-tests (external/apache-harmony/Android.mk)
+# is split into.
+CTS_CORE_CASE_LIST += \
+	android.core.tests.libcore.package.harmony_beans \
+	android.core.tests.libcore.package.harmony_logging \
+	android.core.tests.libcore.package.harmony_prefs \
+	android.core.tests.libcore.package.harmony_sql
+
 # Depend on the full package paths rather than the phony targets to avoid
 # rebuilding the packages every time.
 CTS_CORE_CASES := $(foreach pkg,$(CTS_CORE_CASE_LIST),$(call intermediates-dir-for,APPS,$(pkg))/package.apk)
 BOUNCYCASTLE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,bouncycastle,,COMMON)
 APACHEXML_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,apache-xml,,COMMON)
 OKHTTP_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,okhttp,,COMMON)
+APACHEHARMONY_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,apache-harmony-tests,,COMMON)
 SQLITEJDBC_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,sqlite-jdbc,,COMMON)
 JUNIT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-junit,,COMMON)
 CORETESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests,,COMMON)
+JSR166TESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,jsr166-tests,,COMMON)
 CONSCRYPTTESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,conscrypt-tests,,COMMON)
 
-GEN_CLASSPATH := $(CORE_INTERMEDIATES)/classes.jar:$(CONSCRYPT_INTERMEDIATES)/classes.jar:$(BOUNCYCASTLE_INTERMEDIATES)/classes.jar:$(APACHEXML_INTERMEDIATES)/classes.jar:$(OKHTTP_INTERMEDIATES)/classes.jar:$(JUNIT_INTERMEDIATES)/classes.jar:$(SQLITEJDBC_INTERMEDIATES)/javalib.jar:$(CORETESTS_INTERMEDIATES)/javalib.jar:$(CONSCRYPTTESTS_INTERMEDIATES)/javalib.jar
+GEN_CLASSPATH := $(CORE_INTERMEDIATES)/classes.jar:$(CONSCRYPT_INTERMEDIATES)/classes.jar:$(BOUNCYCASTLE_INTERMEDIATES)/classes.jar:$(APACHEXML_INTERMEDIATES)/classes.jar:$(APACHEHARMONY_INTERMEDIATES)/classes.jar:$(OKHTTP_INTERMEDIATES)/classes.jar:$(JUNIT_INTERMEDIATES)/classes.jar:$(SQLITEJDBC_INTERMEDIATES)/javalib.jar:$(CORETESTS_INTERMEDIATES)/javalib.jar:$(JSR166TESTS_INTERMEDIATES)/javalib.jar:$(CONSCRYPTTESTS_INTERMEDIATES)/javalib.jar
 
 CTS_CORE_XMLS := \
 	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.dalvik.xml \
 	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.sun.xml \
 	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.tests.xml \
 	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.org.xml \
-	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.libcore.xml
+	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.libcore.xml \
+	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.jsr166.xml \
+	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_annotation.xml \
+	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_io.xml \
+	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_lang.xml \
+	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_math.xml \
+	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_net.xml \
+	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_nio.xml \
+	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_text.xml \
+	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_util.xml \
+	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_javax_security.xml \
+	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_beans.xml \
+	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_logging.xml \
+	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_prefs.xml \
+	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_sql.xml \
 
 $(CTS_CORE_XMLS): PRIVATE_CLASSPATH:=$(GEN_CLASSPATH)
 # Why does this depend on javalib.jar instead of classes.jar?  Because
 # build system requires that dependencies use javalib.jar.  If
 # javalib.jar is up-to-date, then classes.jar is as well.  Depending
 # on classes.jar will build the files incorrectly.
-CTS_CORE_XMLS_DEPS := $(CTS_CORE_CASES) $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(HOST_OUT_JAVA_LIBRARIES)/junit.jar $(CORE_INTERMEDIATES)/javalib.jar $(BOUNCYCASTLE_INTERMEDIATES)/javalib.jar $(APACHEXML_INTERMEDIATES)/javalib.jar $(OKHTTP_INTERMEDIATES)/javalib.jar $(SQLITEJDBC_INTERMEDIATES)/javalib.jar $(JUNIT_INTERMEDIATES)/javalib.jar $(CORETESTS_INTERMEDIATES)/javalib.jar $(CONSCRYPTTESTS_INTERMEDIATES)/javalib.jar | $(ACP)
+CTS_CORE_XMLS_DEPS := $(CTS_CORE_CASES) $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(HOST_OUT_JAVA_LIBRARIES)/junit.jar $(CORE_INTERMEDIATES)/javalib.jar $(BOUNCYCASTLE_INTERMEDIATES)/javalib.jar $(APACHEXML_INTERMEDIATES)/javalib.jar $(APACHEHARMONY_INTERMEDIATES)/javalib.jar $(OKHTTP_INTERMEDIATES)/javalib.jar $(SQLITEJDBC_INTERMEDIATES)/javalib.jar $(JUNIT_INTERMEDIATES)/javalib.jar $(CORETESTS_INTERMEDIATES)/javalib.jar $(JSR166TESTS_INTERMEDIATES)/javalib.jar $(CONSCRYPTTESTS_INTERMEDIATES)/javalib.jar build/core/tasks/cts.mk | $(ACP)
 
 $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.dalvik.xml: $(CTS_CORE_XMLS_DEPS)
 	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
 		$(CORETESTS_INTERMEDIATES)/javalib.jar,libcore,\
 		libcore/expectations)
 
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.jsr166.xml: $(CTS_CORE_XMLS_DEPS)
+	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
+	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.jsr166,\
+		cts/tests/core/libcore/jsr166/AndroidManifest.xml,\
+		$(JSR166TESTS_INTERMEDIATES)/javalib.jar,jsr166,\
+		libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_annotation.xml: $(CTS_CORE_XMLS_DEPS)
+	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
+	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_annotation,\
+		cts/tests/core/libcore/harmony_annotation/AndroidManifest.xml,\
+		$(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.annotation.tests,\
+		libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_io.xml: $(CTS_CORE_XMLS_DEPS)
+	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
+	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_io,\
+		cts/tests/core/libcore/harmony_java_io/AndroidManifest.xml,\
+		$(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.tests.java.io,\
+		libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_lang.xml: $(CTS_CORE_XMLS_DEPS)
+	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
+	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_lang,\
+		cts/tests/core/libcore/harmony_java_lang/AndroidManifest.xml,\
+		$(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.tests.java.lang,\
+		libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_math.xml: $(CTS_CORE_XMLS_DEPS)
+	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
+	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_math,\
+		cts/tests/core/libcore/harmony_java_math/AndroidManifest.xml,\
+		$(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.tests.java.math,\
+		libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_net.xml: $(CTS_CORE_XMLS_DEPS)
+	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
+	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_net,\
+		cts/tests/core/libcore/harmony_java_net/AndroidManifest.xml,\
+		$(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.tests.java.net,\
+		libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_nio.xml: $(CTS_CORE_XMLS_DEPS)
+	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
+	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_nio,\
+		cts/tests/core/libcore/harmony_java_nio/AndroidManifest.xml,\
+		$(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.tests.java.nio,\
+		libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_text.xml: $(CTS_CORE_XMLS_DEPS)
+	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
+	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_text,\
+		cts/tests/core/libcore/harmony_java_text/AndroidManifest.xml,\
+		$(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.tests.java.text,\
+		libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_util.xml: $(CTS_CORE_XMLS_DEPS)
+	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
+	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_util,\
+		cts/tests/core/libcore/harmony_java_util/AndroidManifest.xml,\
+		$(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.tests.java.util,\
+		libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_javax_security.xml: $(CTS_CORE_XMLS_DEPS)
+	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
+	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_javax_security,\
+		cts/tests/core/libcore/harmony_javax_security/AndroidManifest.xml,\
+		$(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.tests.javax.security,\
+		libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_beans.xml: $(CTS_CORE_XMLS_DEPS)
+	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
+	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_beans,\
+		cts/tests/core/libcore/harmony_beans/AndroidManifest.xml,\
+		$(APACHEHARMONY_INTERMEDIATES)/javalib.jar,com.android.org.apache.harmony.beans,\
+		libcore/expectations external/apache-harmony/Android.mk)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_logging.xml: $(CTS_CORE_XMLS_DEPS)
+	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
+	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_logging,\
+		cts/tests/core/libcore/harmony_logging/AndroidManifest.xml,\
+		$(APACHEHARMONY_INTERMEDIATES)/javalib.jar,com.android.org.apache.harmony.logging,\
+		libcore/expectations external/apache-harmony/Android.mk)
+
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_prefs.xml: $(CTS_CORE_XMLS_DEPS)
+	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
+	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_prefs,\
+		cts/tests/core/libcore/harmony_prefs/AndroidManifest.xml,\
+		$(APACHEHARMONY_INTERMEDIATES)/javalib.jar,com.android.org.apache.harmony.prefs,\
+		libcore/expectations external/apache-harmony/Android.mk)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_sql.xml: $(CTS_CORE_XMLS_DEPS)
+	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
+	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_sql,\
+		cts/tests/core/libcore/harmony_sql/AndroidManifest.xml,\
+		$(APACHEHARMONY_INTERMEDIATES)/javalib.jar,com.android.org.apache.harmony.sql,\
+		libcore/expectations external/apache-harmony/Android.mk)
+
 # ----- Generate the test descriptions for the vm-tests-tf -----
 #
 CORE_VM_TEST_TF_DESC := $(CTS_TESTCASES_OUT)/android.core.vm-tests-tf.xml

File core/tasks/vendor_module_check.mk