Merge changes Ib1d950e1,I3d020a3c,Ic9594718

* changes:
  Add 2nd arch directories for apps
  Set up rules to build prebuilts for TARGET_2ND_ARCH
  Set up rules to build packages for TARGET_2ND_ARCH
diff --git a/core/envsetup.mk b/core/envsetup.mk
index fb524a4..a348eb7 100644
--- a/core/envsetup.mk
+++ b/core/envsetup.mk
@@ -239,6 +239,8 @@
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES)/lib
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES := $(TARGET_OUT)/lib
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_EXECUTABLES := $(TARGET_OUT_EXECUTABLES)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_APPS := $(TARGET_OUT_APPS)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_APPS_PRIVILEGED := $(TARGET_OUT_APPS_PRIVILEGED)
 
 TARGET_OUT_DATA := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_DATA)
 TARGET_OUT_DATA_EXECUTABLES := $(TARGET_OUT_EXECUTABLES)
@@ -253,6 +255,7 @@
 
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_EXECUTABLES := $(TARGET_OUT_DATA_EXECUTABLES)
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_SHARED_LIBRARIES := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_APPS := $(TARGET_OUT_DATA_APPS)
 
 TARGET_OUT_CACHE := $(PRODUCT_OUT)/cache
 
@@ -270,6 +273,7 @@
 
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_EXECUTABLES := $(TARGET_OUT_VENDOR_EXECUTABLES)
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES := $(TARGET_OUT_VENDOR)/lib
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_APPS := $(TARGET_OUT_VENDOR_APPS)
 
 TARGET_OUT_UNSTRIPPED := $(PRODUCT_OUT)/symbols
 TARGET_OUT_EXECUTABLES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/bin
diff --git a/core/package.mk b/core/package.mk
index 56f2dab..53192b4 100644
--- a/core/package.mk
+++ b/core/package.mk
@@ -25,6 +25,11 @@
 ## be set for you.
 ###########################################################
 
+ifeq ($(TARGET_IS_64_BIT)|$(LOCAL_32BIT_ONLY),true|true)
+LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX)
+else
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+endif
 
 # If this makefile is being read from within an inheritance,
 # use the new values.
@@ -306,7 +311,7 @@
 so_suffix := $($(my_prefix)SHLIB_SUFFIX)
 
 jni_shared_libraries := \
-    $(addprefix $($(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
+    $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
       $(addsuffix $(so_suffix), \
         $(LOCAL_JNI_SHARED_LIBRARIES)))
 
@@ -325,7 +330,7 @@
     LOCAL_PACKAGE_NAME=$(LOCAL_PACKAGE_NAME))
 endif
 jni_shared_libraries += \
-    $(HISTORICAL_NDK_VERSIONS_ROOT)/current/sources/cxx-stl/stlport/libs/$(TARGET_CPU_ABI)/libstlport_shared.so
+    $(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.
@@ -333,7 +338,7 @@
 # sets where they are stored in the apk.)
 
 ifeq ($(LOCAL_JNI_SHARED_LIBRARIES_ABI),)
-    jni_shared_libraries_abi := $(TARGET_CPU_ABI)
+    jni_shared_libraries_abi := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)
 else
     jni_shared_libraries_abi := $(LOCAL_JNI_SHARED_LIBRARIES_ABI)
 endif
@@ -468,3 +473,5 @@
 
 # Reset internal variables.
 all_res_assets :=
+
+LOCAL_2ND_ARCH_VAR_PREFIX :=
diff --git a/core/prebuilt.mk b/core/prebuilt.mk
index 13d4de7..d5fa4ba 100644
--- a/core/prebuilt.mk
+++ b/core/prebuilt.mk
@@ -16,6 +16,15 @@
 $(error dont use LOCAL_PREBUILT_JAVA_LIBRARIES anymore LOCAL_PATH=$(LOCAL_PATH))
 endif
 
+ifneq ($(TARGET_IS_64_BIT)|$(LOCAL_32BIT_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
 
@@ -33,7 +42,7 @@
 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 := $($(my_prefix)OUT_INTERMEDIATE_LIBRARIES)
+  OVERRIDE_BUILT_MODULE_PATH := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)
 endif
 
 ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
@@ -213,3 +222,5 @@
 $(built_module) : $(LOCAL_ADDITIONAL_DEPENDENCIES)
 
 my_prebuilt_src_file :=
+
+LOCAL_2ND_ARCH_VAR_PREFIX :=