Reconcile with jb-mr0-release jb-release - do not merge

Change-Id: Ie56fbb34384a4cf7d00b2ce89fd69ec434396a05
diff --git a/CleanSpec.mk b/CleanSpec.mk
index b1b139a..6d81733 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -122,10 +122,10 @@
 # Changing where ro.carrier value is instantiated for system/build.prop
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
 
-$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
-$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
-$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/app/*)
-$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+# Now we switched to build against Mac OS X SDK 10.6
+$(call add-clean-step, rm -rf $(OUT_DIR)/host/darwin-x86/obj)
+
+$(call add-clean-step, rm -f $(OUT_DIR)/versions_checked.mk)
 
 # ************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
diff --git a/core/Makefile b/core/Makefile
index 78b9f1e..17f45cf 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -352,13 +352,9 @@
 
 BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
 
-ifeq ($(HAVE_SELINUX),true)
-SELINUX_DEPENDS := sepolicy file_contexts seapp_contexts
-endif
-
 # We just build this directly to the install location.
 INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
-$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) $(SELINUX_DEPENDS) | $(MINIGZIP)
+$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) | $(MINIGZIP)
 	$(call pretty,"Target ram disk: $@")
 	$(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $@
 
@@ -707,7 +703,7 @@
 #    $(tests_MODULES))
 endif
 
-FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS) $(SELINUX_DEPENDS)
+FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
 # -----------------------------------------------------------------
 # installed file list
 # Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
@@ -1156,7 +1152,7 @@
 
 $(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
 
-$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS) $(SELINUX_DEPENDS)
+$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS)
 	@echo "Package OTA: $@"
 	$(hide) ./build/tools/releasetools/ota_from_target_files -v \
 	   -p $(HOST_OUT) \
@@ -1184,7 +1180,7 @@
 $(INTERNAL_UPDATE_PACKAGE_TARGET): extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
 endif
 
-$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS) $(SELINUX_DEPENDS)
+$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS)
 	@echo "Package: $@"
 	$(hide) ./build/tools/releasetools/img_from_target_files -v \
 	   -s $(extensions) \
@@ -1298,7 +1294,7 @@
 
 # -----------------------------------------------------------------
 # The emulator package
-
+ifeq ($(BUILD_EMULATOR),true)
 INTERNAL_EMULATOR_PACKAGE_FILES += \
         $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
         prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
@@ -1314,6 +1310,7 @@
 	@echo "Package: $@"
 	$(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
 
+endif
 # -----------------------------------------------------------------
 # Old PDK stuffs, retired
 # The pdk package (Platform Development Kit)
@@ -1433,6 +1430,7 @@
 	done; \
 	if [ $$FAIL ]; then exit 1; fi
 	$(hide) ( \
+		ATREE_STRIP="strip -x" \
 		$(HOST_OUT_EXECUTABLES)/atree \
 		$(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
 			-m $(PRIVATE_DEP_FILE) \
@@ -1487,6 +1485,7 @@
 # These are some additional build tasks that need to be run.
 include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
 -include $(sort $(wildcard vendor/*/build/tasks/*.mk))
+-include $(sort $(wildcard device/*/build/tasks/*.mk))
 
 # -----------------------------------------------------------------
 # Create SDK repository packages. Must be done after tasks/* since
diff --git a/core/binary.mk b/core/binary.mk
index 04ac90b..04e0128 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -148,6 +148,15 @@
   LOCAL_LDFLAGS += $(TARGET_FDO_CFLAGS)
 endif
 
+####################################################
+## Add profiling flags if aprof is turned on
+####################################################
+ifeq ($(strip $(LOCAL_ENABLE_APROF)),true)
+  # -ffunction-sections and -fomit-frame-pointer are conflict with -pg
+  LOCAL_CFLAGS += -fno-omit-frame-pointer -fno-function-sections -pg
+  LOCAL_CPPFLAGS += -fno-omit-frame-pointer -fno-function-sections -pg
+endif
+
 ###########################################################
 ## Explicitly declare assembly-only __ASSEMBLY__ macro for
 ## assembly source
diff --git a/core/build_id.mk b/core/build_id.mk
index 2c19963..e954794 100644
--- a/core/build_id.mk
+++ b/core/build_id.mk
@@ -1,4 +1,3 @@
-
 #
 # Copyright (C) 2008 The Android Open Source Project
 #
@@ -14,9 +13,20 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
+
+#
+# Defines branch-specific values.
+#
+
 # BUILD_ID is usually used to specify the branch name
 # (like "MAIN") or a branch name and a release candidate
-# (like "CRB01").  It must be a single word, and is
+# (like "TC1-RC5").  It must be a single word, and is
 # capitalized by convention.
+#
+BUILD_ID := OPENMASTER
 
-export BUILD_ID=JRO03R
+# DISPLAY_BUILD_NUMBER should only be set for development branches,
+# If set, the BUILD_NUMBER (cl) is appended to the BUILD_ID for
+# a more descriptive BUILD_ID_DISPLAY, otherwise BUILD_ID_DISPLAY
+# is the same as BUILD_ID
+DISPLAY_BUILD_NUMBER := true
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index 5209a04..3137152 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -79,6 +79,8 @@
 LOCAL_COPY_HEADERS:=
 LOCAL_FORCE_STATIC_EXECUTABLE:=
 LOCAL_ADDITIONAL_DEPENDENCIES:=
+LOCAL_ENABLE_APROF:=
+LOCAL_ENABLE_APROF_JNI:=
 LOCAL_COMPRESS_MODULE_SYMBOLS:=
 LOCAL_STRIP_MODULE:=
 LOCAL_POST_PROCESS_COMMAND:=true
@@ -123,6 +125,7 @@
 LOCAL_CLANG:=
 LOCAL_ADDRESS_SANITIZER:=
 LOCAL_JAR_EXCLUDE_FILES:=
+LOCAL_SOURCE_FILES_ALL_GENERATED:= # '',true
 
 # Trim MAKEFILE_LIST so that $(call my-dir) doesn't need to
 # iterate over thousands of entries every time.
diff --git a/core/combo/HOST_darwin-x86.mk b/core/combo/HOST_darwin-x86.mk
index 198c53f..85bb2cd 100644
--- a/core/combo/HOST_darwin-x86.mk
+++ b/core/combo/HOST_darwin-x86.mk
@@ -29,27 +29,29 @@
 HOST_GLOBAL_LDFLAGS += -m32
 endif # BUILD_HOST_64bit
 
-# Use the Mac OSX SDK 10.5 if the build host is 10.6
 build_mac_version := $(shell sw_vers -productVersion)
-ifneq ($(filter 10.6.%, $(build_mac_version)),)
-sdk_105_root := /Developer/SDKs/MacOSX10.5.sdk
-ifeq ($(wildcard $(sdk_105_root)),)
+mac_sdk_version := 10.6
+mac_sdk_root := /Developer/SDKs/MacOSX$(mac_sdk_version).sdk
+ifeq ($(wildcard $(mac_sdk_root)),)
+recent_xcode4_mac_sdk_root := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(mac_sdk_version).sdk
+ifeq ($(wildcard $(recent_xcode4_mac_sdk_root)),)
 $(warning *****************************************************)
-$(warning * You are building on Mac OSX 10.6.)
-$(warning * Can not find SDK 10.5 at $(sdk_105_root))
+$(warning * Can not find SDK $(mac_sdk_version) at $(mac_sdk_root))
+$(warning * or $(recent_xcode4_mac_sdk_root))
 $(warning *****************************************************)
 $(error Stop.)
 endif
+mac_sdk_root := $(recent_xcode4_mac_sdk_root)
+endif
 
-HOST_GLOBAL_CFLAGS += -isysroot $(sdk_105_root) -mmacosx-version-min=10.5
-HOST_GLOBAL_LDFLAGS += -isysroot $(sdk_105_root) -mmacosx-version-min=10.5
-endif # build_mac_version is 10.6
+HOST_GLOBAL_CFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version)
+HOST_GLOBAL_LDFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version)
 
 HOST_GLOBAL_CFLAGS += -fPIC
 HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error
 
-HOST_CC := $(CC)
-HOST_CXX := $(CXX)
+HOST_CC := gcc
+HOST_CXX := g++
 HOST_AR := $(AR)
 HOST_STRIP := $(STRIP)
 HOST_STRIP_COMMAND = $(HOST_STRIP) --strip-debug $< -o $@
@@ -59,7 +61,7 @@
 
 HOST_GLOBAL_CFLAGS += \
 	-include $(call select-android-config-h,darwin-x86)
-ifneq ($(filter 10.7.%, $(build_mac_version)),)
+ifneq ($(filter 10.7 10.7.% 10.8 10.8.%, $(build_mac_version)),)
        HOST_RUN_RANLIB_AFTER_COPYING := false
 else
        HOST_RUN_RANLIB_AFTER_COPYING := true
diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk
index 4a461f8..14c3d28 100644
--- a/core/combo/TARGET_linux-arm.mk
+++ b/core/combo/TARGET_linux-arm.mk
@@ -181,7 +181,7 @@
 TARGET_FDO_LIB:=
 
 target_libgcov := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) \
-        --print-file-name=libgcov.a)
+        -print-file-name=libgcov.a)
 ifneq ($(strip $(BUILD_FDO_INSTRUMENT)),)
   # Set BUILD_FDO_INSTRUMENT=true to turn on FDO instrumentation.
   # The profile will be generated on /data/local/tmp/profile on the device.
@@ -280,6 +280,9 @@
 	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
 	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_DYNAMIC_O)) \
 	$(PRIVATE_ALL_OBJECTS) \
+	-Wl,--whole-archive \
+	$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
+	-Wl,--no-whole-archive \
 	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
 	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
@@ -299,6 +302,9 @@
 	$(TARGET_GLOBAL_LDFLAGS) \
 	$(PRIVATE_LDFLAGS) \
 	$(PRIVATE_ALL_OBJECTS) \
+	-Wl,--whole-archive \
+	$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
+	-Wl,--no-whole-archive \
 	$(call normalize-target-libraries,$(filter-out %libc_nomalloc.a,$(filter-out %libc.a,$(PRIVATE_ALL_STATIC_LIBRARIES)))) \
 	-Wl,--start-group \
 	$(call normalize-target-libraries,$(filter %libc.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \
diff --git a/core/combo/TARGET_linux-mips.mk b/core/combo/TARGET_linux-mips.mk
new file mode 100644
index 0000000..a3a891e
--- /dev/null
+++ b/core/combo/TARGET_linux-mips.mk
@@ -0,0 +1,284 @@
+#
+# Copyright (C) 2010 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.
+#
+
+# Configuration for Linux on MIPS.
+# Included by combo/select.mk
+
+# You can set TARGET_ARCH_VARIANT to use an arch version other
+# than mips32r2-fp. Each value should correspond to a file named
+# $(BUILD_COMBOS)/arch/<name>.mk which must contain
+# makefile variable definitions similar to the preprocessor
+# defines in system/core/include/arch/<combo>/AndroidConfig.h. Their
+# purpose is to allow module Android.mk files to selectively compile
+# different versions of code based upon the funtionality and
+# instructions available in a given architecture version.
+#
+# The blocks also define specific arch_variant_cflags, which
+# include defines, and compiler settings for the given architecture
+# version.
+#
+ifeq ($(strip $(TARGET_ARCH_VARIANT)),)
+TARGET_ARCH_VARIANT := mips32r2-fp
+endif
+
+TARGET_ARCH_SPECIFIC_MAKEFILE := $(BUILD_COMBOS)/arch/$(TARGET_ARCH)/$(TARGET_ARCH_VARIANT).mk
+ifeq ($(strip $(wildcard $(TARGET_ARCH_SPECIFIC_MAKEFILE))),)
+$(error Unknown MIPS architecture variant: $(TARGET_ARCH_VARIANT))
+endif
+
+include $(TARGET_ARCH_SPECIFIC_MAKEFILE)
+
+# You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
+ifeq ($(strip $(TARGET_TOOLS_PREFIX)),)
+TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/mips/mipsel-linux-android-4.6
+TARGET_TOOLS_PREFIX := $(TARGET_TOOLCHAIN_ROOT)/bin/mipsel-linux-android-
+endif
+
+# Only define these if there's actually a gcc in there.
+# The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it.
+ifneq ($(wildcard $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)),)
+    TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)
+    TARGET_CXX := $(TARGET_TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX)
+    TARGET_AR := $(TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
+    TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
+    TARGET_LD := $(TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
+    TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX)
+    ifeq ($(TARGET_BUILD_VARIANT),user)
+        TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-all $< -o $@
+    else
+        TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-all $< -o $@ && \
+	    $(TARGET_OBJCOPY) --add-gnu-debuglink=$< $@
+    endif
+endif
+
+TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
+
+TARGET_mips_CFLAGS :=	-O2 \
+			-fomit-frame-pointer \
+			-fno-strict-aliasing    \
+			-funswitch-loops
+
+# Set FORCE_MIPS_DEBUGGING to "true" in your buildspec.mk
+# or in your environment to gdb debugging easier.
+# Don't forget to do a clean build.
+ifeq ($(FORCE_MIPS_DEBUGGING),true)
+  TARGET_mips_CFLAGS += -fno-omit-frame-pointer
+endif
+
+android_config_h := $(call select-android-config-h,linux-mips)
+arch_include_dir := $(dir $(android_config_h))
+
+TARGET_GLOBAL_CFLAGS += \
+			$(TARGET_mips_CFLAGS) \
+			-Ulinux -U__unix -U__unix__ -Umips \
+			-fpic \
+			-ffunction-sections \
+			-fdata-sections \
+			-funwind-tables \
+			-Werror=format-security \
+			$(arch_variant_cflags) \
+			-include $(android_config_h) \
+			-I $(arch_include_dir)
+
+# This warning causes dalvik not to build with gcc 4.6.x and -Werror.
+# We cannot turn it off blindly since the option is not available
+# in gcc-4.4.x.
+ifneq ($(filter 4.6.%, $(shell $(TARGET_CC) --version)),)
+TARGET_GLOBAL_CFLAGS += -Wno-unused-but-set-variable \
+                        -fno-strict-volatile-bitfields
+endif
+
+# This is to avoid the dreaded warning compiler message:
+#   note: the mangling of 'va_list' has changed in GCC 4.4
+#
+# The fact that the mangling changed does not affect the NDK ABI
+# very fortunately (since none of the exposed APIs used va_list
+# in their exported C++ functions). Also, GCC 4.5 has already
+# removed the warning from the compiler.
+#
+TARGET_GLOBAL_CFLAGS += -Wno-psabi
+
+ifneq ($(ARCH_MIPS_PAGE_SHIFT),)
+TARGET_GLOBAL_CFLAGS += -DPAGE_SHIFT=$(ARCH_MIPS_PAGE_SHIFT)
+endif
+
+TARGET_GLOBAL_LDFLAGS += \
+			$(arch_variant_ldflags)
+
+TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden \
+				-fno-use-cxa-atexit
+
+# More flags/options can be added here
+TARGET_RELEASE_CFLAGS := \
+			-DNDEBUG \
+			-g \
+			-Wstrict-aliasing=2 \
+			-fgcse-after-reload \
+			-frerun-cse-after-loop \
+			-frename-registers
+
+libc_root := bionic/libc
+libm_root := bionic/libm
+libstdc++_root := bionic/libstdc++
+libthread_db_root := bionic/libthread_db
+
+
+## on some hosts, the target cross-compiler is not available so do not run this command
+ifneq ($(wildcard $(TARGET_CC)),)
+# We compile with the global cflags to ensure that
+# any flags which affect libgcc are correctly taken
+# into account.
+TARGET_LIBGCC := \
+  $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) -print-file-name=libgcc.a)
+LIBGCC_EH := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) -print-file-name=libgcc_eh.a)
+ifneq ($(LIBGCC_EH),libgcc_eh.a)
+  TARGET_LIBGCC += $(LIBGCC_EH)
+endif
+endif
+
+# Define FDO (Feedback Directed Optimization) options.
+
+TARGET_FDO_CFLAGS:=
+TARGET_FDO_LIB:=
+
+target_libgcov := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) \
+        --print-file-name=libgcov.a)
+ifneq ($(strip $(BUILD_FDO_INSTRUMENT)),)
+  # Set BUILD_FDO_INSTRUMENT=true to turn on FDO instrumentation.
+  # The profile will be generated on /data/local/tmp/profile on the device.
+  TARGET_FDO_CFLAGS := -fprofile-generate=/data/local/tmp/profile -DANDROID_FDO
+  TARGET_FDO_LIB := $(target_libgcov)
+else
+  # If BUILD_FDO_INSTRUMENT is turned off, then consider doing the FDO optimizations.
+  # Set TARGET_FDO_PROFILE_PATH to set a custom profile directory for your build.
+  ifeq ($(strip $(TARGET_FDO_PROFILE_PATH)),)
+    TARGET_FDO_PROFILE_PATH := fdo/profiles/$(TARGET_ARCH)/$(TARGET_ARCH_VARIANT)
+  else
+    ifeq ($(strip $(wildcard $(TARGET_FDO_PROFILE_PATH))),)
+      $(warning Custom TARGET_FDO_PROFILE_PATH supplied, but directory does not exist. Turn off FDO.)
+    endif
+  endif
+
+  # If the FDO profile directory can't be found, then FDO is off.
+  ifneq ($(strip $(wildcard $(TARGET_FDO_PROFILE_PATH))),)
+    TARGET_FDO_CFLAGS := -fprofile-use=$(TARGET_FDO_PROFILE_PATH) -DANDROID_FDO
+    TARGET_FDO_LIB := $(target_libgcov)
+  endif
+endif
+
+
+# unless CUSTOM_KERNEL_HEADERS is defined, we're going to use
+# symlinks located in out/ to point to the appropriate kernel
+# headers. see 'config/kernel_headers.make' for more details
+#
+ifneq ($(CUSTOM_KERNEL_HEADERS),)
+    KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS)
+    KERNEL_HEADERS_ARCH   := $(CUSTOM_KERNEL_HEADERS)
+else
+    KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common
+    KERNEL_HEADERS_ARCH   := $(libc_root)/kernel/arch-$(TARGET_ARCH)
+endif
+KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
+
+TARGET_C_INCLUDES := \
+	$(libc_root)/arch-mips/include \
+	$(libc_root)/include \
+	$(libstdc++_root)/include \
+	$(KERNEL_HEADERS) \
+	$(libm_root)/include \
+	$(libm_root)/include/mips \
+	$(libthread_db_root)/include
+
+TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
+TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
+TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
+
+TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_so.o
+TARGET_CRTEND_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_so.o
+
+TARGET_STRIP_MODULE:=true
+
+TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm
+
+TARGET_CUSTOM_LD_COMMAND := true
+
+# Enable the Dalvik JIT compiler if not already specified.
+ifeq ($(strip $(WITH_JIT)),)
+    WITH_JIT := true
+endif
+
+define transform-o-to-shared-lib-inner
+$(hide) $(PRIVATE_CXX) \
+	-nostdlib -Wl,-soname,$(notdir $@) \
+	-Wl,--gc-sections \
+	-shared -Bsymbolic \
+	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \
+	$(PRIVATE_ALL_OBJECTS) \
+	-Wl,--whole-archive \
+	$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
+	-Wl,--no-whole-archive \
+	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
+	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
+	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
+	-o $@ \
+	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
+	$(PRIVATE_LDFLAGS) \
+	$(PRIVATE_TARGET_FDO_LIB) \
+	$(PRIVATE_TARGET_LIBGCC) \
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O))
+endef
+
+define transform-o-to-executable-inner
+$(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic \
+	-Wl,-dynamic-linker,/system/bin/linker \
+	-Wl,--gc-sections \
+	-Wl,-z,nocopyreloc \
+	-o $@ \
+	$(TARGET_GLOBAL_LD_DIRS) \
+	-Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
+	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_DYNAMIC_O)) \
+	$(PRIVATE_ALL_OBJECTS) \
+	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
+	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
+	$(TARGET_GLOBAL_LDFLAGS) \
+	$(PRIVATE_LDFLAGS) \
+	$(TARGET_FDO_LIB) \
+	$(TARGET_LIBGCC) \
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O))
+endef
+
+define transform-o-to-static-executable-inner
+$(hide) $(PRIVATE_CXX) -nostdlib -Bstatic \
+	-Wl,--gc-sections \
+	-o $@ \
+	$(TARGET_GLOBAL_LD_DIRS) \
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_STATIC_O)) \
+	$(TARGET_GLOBAL_LDFLAGS) \
+	$(PRIVATE_LDFLAGS) \
+	$(PRIVATE_ALL_OBJECTS) \
+	$(call normalize-target-libraries,$(filter-out %libc_nomalloc.a,$(filter-out %libc.a,$(PRIVATE_ALL_STATIC_LIBRARIES)))) \
+	-Wl,--start-group \
+	$(call normalize-target-libraries,$(filter %libc.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \
+	$(call normalize-target-libraries,$(filter %libc_nomalloc.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \
+	$(TARGET_FDO_LIB) \
+	$(TARGET_LIBGCC) \
+	-Wl,--end-group \
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O))
+endef
diff --git a/core/combo/TARGET_linux-sh.mk b/core/combo/TARGET_linux-sh.mk
deleted file mode 100644
index 88c6215..0000000
--- a/core/combo/TARGET_linux-sh.mk
+++ /dev/null
@@ -1,179 +0,0 @@
-#
-# Copyright (C) 2006 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.
-#
-
-# Configuration for Linux on SuperH.
-# Included by combo/select.make
-
-# You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
-ifeq ($(strip $(TARGET_TOOLS_PREFIX)),)
-TARGET_TOOLCHAIN_ROOT := prebuilt/$(HOST_PREBUILT_TAG)/toolchain/sh-4.3.3
-TARGET_TOOLS_PREFIX := $(TARGET_TOOLCHAIN_ROOT)/bin/sh-linux-gnu-
-endif
-
-TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)
-TARGET_CXX := $(TARGET_TOOLS_PREFIX)c++$(HOST_EXECUTABLE_SUFFIX)
-TARGET_AR := $(TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
-TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
-TARGET_LD := $(TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
-TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX)
-
-ifeq ($(TARGET_BUILD_VARIANT),user)
-TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-debug $< -o $@
-else
-TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-debug $< -o $@ && \
-	$(TARGET_OBJCOPY) --add-gnu-debuglink=$< $@
-endif
-
-TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
-
-TARGET_sh_release_CFLAGS :=     -O2 \
-                                -fomit-frame-pointer \
-                                -fstrict-aliasing    \
-                                -funswitch-loops     \
-                                -finline-limit=300
-
-# When building for debug, compile everything as superh.
-TARGET_sh_debug_CFLAGS := $(TARGET_sh_release_CFLAGS) -fno-omit-frame-pointer -fno-strict-aliasing
-
-TARGET_GLOBAL_CFLAGS += \
-			-fpic \
-			-ffunction-sections \
-			-funwind-tables \
-			-fstack-protector \
-			-include $(call select-android-config-h,linux-sh)
-
-TARGET_GLOBAL_CPPFLAGS += \
-			-fno-use-cxa-atexit \
-			-fvisibility-inlines-hidden
-
-TARGET_RELEASE_CFLAGS := \
-			-DSK_RELEASE -DNDEBUG \
-			-O2 -g \
-			-Wstrict-aliasing=2 \
-			-finline-functions \
-			-fno-inline-functions-called-once \
-			-fgcse-after-reload \
-			-frerun-cse-after-loop \
-			-frename-registers \
-			-fno-builtin
-
-libc_root := bionic/libc
-libm_root := bionic/libm
-libstdc++_root := bionic/libstdc++
-libthread_db_root := bionic/libthread_db
-
-
-## on some hosts, the target cross-compiler is not available so do not run this command
-ifneq ($(wildcard $(TARGET_CC)),)
-# We compile with the global cflags to ensure that
-# any flags which affect libgcc are correctly taken
-# into account.
-LIBGCC_FILENAME := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) -print-libgcc-file-name)
-LIBGCC_EH_FILENAME := $(subst libgcc,libgcc_eh,$(LIBGCC_FILENAME))
-TARGET_LIBGCC := $(LIBGCC_EH_FILENAME) $(LIBGCC_FILENAME)
-endif
-
-# unless CUSTOM_KERNEL_HEADERS is defined, we're going to use
-# symlinks located in out/ to point to the appropriate kernel
-# headers. see 'config/kernel_headers.make' for more details
-#
-ifneq ($(CUSTOM_KERNEL_HEADERS),)
-    KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS)
-    KERNEL_HEADERS_ARCH   := $(CUSTOM_KERNEL_HEADERS)
-else
-    KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common
-    KERNEL_HEADERS_ARCH   := $(libc_root)/kernel/arch-$(TARGET_ARCH)
-endif
-KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
-
-TARGET_C_INCLUDES := \
-	$(libc_root)/arch-sh/include \
-	$(libc_root)/include \
-	$(libstdc++_root)/include \
-	$(KERNEL_HEADERS) \
-	$(libm_root)/include \
-	$(libm_root)/include/sh \
-	$(libthread_db_root)/include
-
-TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
-TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
-TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
-
-TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/sobegin.o
-TARGET_CRTEND_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/soend.o
-
-TARGET_STRIP_MODULE:=true
-
-TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm
-
-TARGET_CUSTOM_LD_COMMAND := true
-define transform-o-to-shared-lib-inner
-$(hide) $(PRIVATE_CXX) \
-	-nostdlib -Wl,-soname,$(notdir $@) -Wl,-T,$(BUILD_SYSTEM)/shlelf.xsc \
-	-Wl,--gc-sections -Wl,-z,norelro \
-	-Wl,-shared,-Bsymbolic \
-	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \
-	$(PRIVATE_ALL_OBJECTS) \
-	-Wl,--whole-archive \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
-	-Wl,--no-whole-archive \
-	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
-	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-	-o $@ \
-	$(PRIVATE_LDFLAGS) \
-	$(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \
-	$(PRIVATE_TARGET_LIBGCC) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O))
-endef
-
-define transform-o-to-executable-inner
-$(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic  -Wl,-T,$(BUILD_SYSTEM)/shlelf.x \
-	-Wl,-dynamic-linker,/system/bin/linker \
-	-Wl,--gc-sections -Wl,-z,norelro \
-	-Wl,-z,nocopyreloc \
-	-o $@ \
-	$(TARGET_GLOBAL_LD_DIRS) \
-	-Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_DYNAMIC_O)) \
-	$(PRIVATE_ALL_OBJECTS) \
-	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
-	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
-	$(PRIVATE_LDFLAGS) \
-	$(TARGET_LIBGCC) \
-	$(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O))
-endef
-
-define transform-o-to-static-executable-inner
-$(hide) $(PRIVATE_CXX) -nostdlib -Bstatic  -Wl,-T,$(BUILD_SYSTEM)/shlelf.x \
-	-Wl,--gc-sections -Wl,-z,norelro \
-	-o $@ \
-	$(TARGET_GLOBAL_LD_DIRS) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_STATIC_O)) \
-	$(PRIVATE_LDFLAGS) \
-	$(PRIVATE_ALL_OBJECTS) \
-	-Wl,--start-group \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
-	-Wl,--end-group \
-	$(TARGET_LIBGCC) \
-	$(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O))
-endef
diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk
index dc4afb8..9c0f7b9 100644
--- a/core/combo/TARGET_linux-x86.mk
+++ b/core/combo/TARGET_linux-x86.mk
@@ -36,8 +36,8 @@
 
 # You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
 ifeq ($(strip $(TARGET_TOOLS_PREFIX)),)
-TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/x86/i686-android-linux-4.4.3
-TARGET_TOOLS_PREFIX := $(TARGET_TOOLCHAIN_ROOT)/bin/i686-android-linux-
+TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/x86/i686-linux-android-4.6
+TARGET_TOOLS_PREFIX := $(TARGET_TOOLCHAIN_ROOT)/bin/i686-linux-android-
 endif
 
 TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)
@@ -104,7 +104,7 @@
 # however, there have been reports that this is sometimes not the case. So make
 # them explicit here unless we have the time to carefully check it
 #
-TARGET_GLOBAL_CFLAGS += -mstackrealign -msse3 -mfpmath=sse
+TARGET_GLOBAL_CFLAGS += -mstackrealign -msse3 -mfpmath=sse -m32
 
 # XXX: These flags should not be defined here anymore. Instead, the Android.mk
 # of the modules that depend on these features should instead check the
@@ -186,11 +186,14 @@
 endef
 
 
+# Add -fuse-ld=bfd because ld.gold doesn't support "--copy-dt-needed-entries".
 define transform-o-to-executable-inner
 $(hide) $(PRIVATE_CXX) \
 	$(TARGET_GLOBAL_LDFLAGS) \
 	-nostdlib -Bdynamic \
 	-Wl,-dynamic-linker,/system/bin/linker \
+	-Wl,--copy-dt-needed-entries \
+	-fuse-ld=bfd \
 	-Wl,-z,nocopyreloc \
 	-fPIE -pie \
 	-o $@ \
@@ -199,6 +202,9 @@
 	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
 	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_DYNAMIC_O)) \
 	$(PRIVATE_ALL_OBJECTS) \
+	-Wl,--whole-archive \
+	$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
+	-Wl,--no-whole-archive \
 	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
 	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
@@ -216,6 +222,9 @@
 	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_STATIC_O)) \
 	$(PRIVATE_LDFLAGS) \
 	$(PRIVATE_ALL_OBJECTS) \
+	-Wl,--whole-archive \
+	$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
+	-Wl,--no-whole-archive \
 	-Wl,--start-group \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
 	$(TARGET_LIBGCC) \
diff --git a/core/combo/arch/mips/mips32-fp.mk b/core/combo/arch/mips/mips32-fp.mk
new file mode 100644
index 0000000..e60bdac
--- /dev/null
+++ b/core/combo/arch/mips/mips32-fp.mk
@@ -0,0 +1,14 @@
+# Configuration for Android on MIPS.
+# Generating binaries for MIPS32/hard-float/little-endian
+
+ARCH_MIPS_HAS_FPU	:=true
+ARCH_HAVE_ALIGNED_DOUBLES :=true
+arch_variant_cflags := \
+    -EL \
+    -march=mips32 \
+    -mtune=mips32 \
+    -mips32 \
+    -mhard-float
+
+arch_variant_ldflags := \
+    -EL
diff --git a/core/combo/arch/mips/mips32.mk b/core/combo/arch/mips/mips32.mk
new file mode 100644
index 0000000..35ef0d8
--- /dev/null
+++ b/core/combo/arch/mips/mips32.mk
@@ -0,0 +1,12 @@
+# Configuration for Android on MIPS.
+# Generating binaries for MIPS32/soft-float/little-endian
+
+arch_variant_cflags := \
+    -EL \
+    -march=mips32 \
+    -mtune=mips32 \
+    -mips32 \
+    -msoft-float
+
+arch_variant_ldflags := \
+    -EL
diff --git a/core/combo/arch/mips/mips32r2-fp.mk b/core/combo/arch/mips/mips32r2-fp.mk
new file mode 100644
index 0000000..a407f00
--- /dev/null
+++ b/core/combo/arch/mips/mips32r2-fp.mk
@@ -0,0 +1,14 @@
+# Configuration for Android on MIPS.
+# Generating binaries for MIPS32R2/hard-float/little-endian
+
+ARCH_MIPS_HAS_FPU	:=true
+ARCH_HAVE_ALIGNED_DOUBLES :=true
+arch_variant_cflags := \
+    -EL \
+    -march=mips32r2 \
+    -mtune=mips32r2 \
+    -mips32r2 \
+    -mhard-float
+
+arch_variant_ldflags := \
+    -EL
diff --git a/core/combo/arch/mips/mips32r2.mk b/core/combo/arch/mips/mips32r2.mk
new file mode 100644
index 0000000..369d499
--- /dev/null
+++ b/core/combo/arch/mips/mips32r2.mk
@@ -0,0 +1,12 @@
+# Configuration for Android on MIPS.
+# Generating binaries for MIPS32R2/soft-float/little-endian
+
+arch_variant_cflags := \
+    -EL \
+    -march=mips32r2 \
+    -mtune=mips32r2 \
+    -mips32r2 \
+    -msoft-float
+
+arch_variant_ldflags := \
+    -EL
diff --git a/core/combo/arch/mips/mips32r2dsp-fp.mk b/core/combo/arch/mips/mips32r2dsp-fp.mk
new file mode 100644
index 0000000..886872d
--- /dev/null
+++ b/core/combo/arch/mips/mips32r2dsp-fp.mk
@@ -0,0 +1,17 @@
+# Configuration for Android on MIPS.
+# Generating binaries for MIPS32R2/hard-float/little-endian/dsp
+
+ARCH_MIPS_HAS_DSP  	:=true
+ARCH_MIPS_DSP_REV	:=1
+ARCH_MIPS_HAS_FPU       :=true
+ARCH_HAVE_ALIGNED_DOUBLES :=true
+arch_variant_cflags := \
+    -EL \
+    -march=mips32r2 \
+    -mtune=mips32r2 \
+    -mips32r2 \
+    -mhard-float \
+    -mdsp
+
+arch_variant_ldflags := \
+    -EL
diff --git a/core/combo/arch/mips/mips32r2dsp.mk b/core/combo/arch/mips/mips32r2dsp.mk
new file mode 100644
index 0000000..e67adc7
--- /dev/null
+++ b/core/combo/arch/mips/mips32r2dsp.mk
@@ -0,0 +1,16 @@
+# Configuration for Android on MIPS.
+# Generating binaries for MIPS32R2/soft-float/little-endian/dsp
+
+ARCH_MIPS_HAS_DSP  	:=true
+ARCH_MIPS_DSP_REV	:=1
+
+arch_variant_cflags := \
+    -EL \
+    -march=mips32r2 \
+    -mtune=mips32r2 \
+    -mips32r2 \
+    -msoft-float \
+    -mdsp
+
+arch_variant_ldflags := \
+    -EL
diff --git a/core/combo/arch/mips/mips32r2dspr2-fp.mk b/core/combo/arch/mips/mips32r2dspr2-fp.mk
new file mode 100644
index 0000000..27e090d
--- /dev/null
+++ b/core/combo/arch/mips/mips32r2dspr2-fp.mk
@@ -0,0 +1,17 @@
+# Configuration for Android on MIPS.
+# Generating binaries for MIPS32R2/hard-float/little-endian/dsp
+
+ARCH_MIPS_HAS_DSP  	:=true
+ARCH_MIPS_DSP_REV	:=2
+ARCH_MIPS_HAS_FPU       :=true
+ARCH_HAVE_ALIGNED_DOUBLES :=true
+arch_variant_cflags := \
+    -EL \
+    -march=mips32r2 \
+    -mtune=mips32r2 \
+    -mips32r2 \
+    -mhard-float \
+    -mdspr2
+
+arch_variant_ldflags := \
+    -EL
diff --git a/core/combo/arch/mips/mips32r2dspr2.mk b/core/combo/arch/mips/mips32r2dspr2.mk
new file mode 100644
index 0000000..c493d9a
--- /dev/null
+++ b/core/combo/arch/mips/mips32r2dspr2.mk
@@ -0,0 +1,16 @@
+# Configuration for Android on MIPS.
+# Generating binaries for MIPS32R2/soft-float/little-endian/dsp
+
+ARCH_MIPS_HAS_DSP  	:=true
+ARCH_MIPS_DSP_REV	:=2
+
+arch_variant_cflags := \
+    -EL \
+    -march=mips32r2 \
+    -mtune=mips32r2 \
+    -mips32r2 \
+    -msoft-float \
+    -mdspr2
+
+arch_variant_ldflags := \
+    -EL
diff --git a/core/combo/select.mk b/core/combo/select.mk
index 803cfc0..e485d00 100644
--- a/core/combo/select.mk
+++ b/core/combo/select.mk
@@ -60,6 +60,23 @@
 include $(BUILD_COMBOS)/$(combo_target)$(combo_os_arch).mk
 
 ifneq ($(USE_CCACHE),)
+  # The default check uses size and modification time, causing false misses
+  # since the mtime depends when the repo was checked out
+  export CCACHE_COMPILERCHECK := content
+
+  # See man page, optimizations to get more cache hits
+  # implies that __DATE__ and __TIME__ are not critical for functionality.
+  # Ignore include file modification time since it will depend on when
+  # the repo was checked out
+  export CCACHE_SLOPPINESS := time_macros,include_file_mtime,file_macro
+
+  # Turn all preprocessor absolute paths into relative paths.
+  # Fixes absolute paths in preprocessed source due to use of -g.
+  # We don't really use system headers much so the rootdir is
+  # fine; ensures these paths are relative for all Android trees
+  # on a workstation.
+  export CCACHE_BASEDIR := /
+
   CCACHE_HOST_TAG := $(HOST_PREBUILT_TAG)
   # If we are cross-compiling Windows binaries on Linux
   # then use the linux ccache binary instead.
diff --git a/core/config.mk b/core/config.mk
index f02fbef..03e4245 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -148,6 +148,9 @@
   $(error Multiple board config files for TARGET_DEVICE $(TARGET_DEVICE): $(board_config_mk))
 endif
 include $(board_config_mk)
+ifeq ($(TARGET_ARCH),)
+  $(error TARGET_ARCH not defined by board config: $(board_config_mk))
+endif
 TARGET_DEVICE_DIR := $(patsubst %/,%,$(dir $(board_config_mk)))
 board_config_mk :=
 
@@ -326,7 +329,7 @@
 ifeq ($(HOST_OS),darwin)
 dir := $(HOST_OS)-$(HOST_ARCH)
 endif
-OLD_FLEX := prebuilt/$(HOST_PREBUILT_TAG)/flex/flex-2.5.4a$(HOST_EXECUTABLE_SUFFIX)
+OLD_FLEX := prebuilts/misc/$(HOST_PREBUILT_TAG)/flex/flex-2.5.4a$(HOST_EXECUTABLE_SUFFIX)
 
 ifeq ($(HOST_OS),darwin)
 # Mac OS' screwy version of java uses a non-standard directory layout
diff --git a/core/definitions.mk b/core/definitions.mk
index 9fe0a11..c1757f3 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -883,7 +883,7 @@
 @echo "target $(PRIVATE_ARM_MODE) C++: $(PRIVATE_MODULE) <= $<"
 $(hide) $(PRIVATE_CXX) \
 	$(addprefix -I , $(PRIVATE_C_INCLUDES)) \
-	@$(PRIVATE_IMPORT_INCLUDES) \
+	$(shell cat $(PRIVATE_IMPORT_INCLUDES)) \
 	$(addprefix -isystem ,\
 	    $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
 	        $(filter-out $(PRIVATE_C_INCLUDES), \
@@ -913,7 +913,7 @@
 @mkdir -p $(dir $@)
 $(hide) $(PRIVATE_CC) \
 	$(addprefix -I , $(PRIVATE_C_INCLUDES)) \
-	@$(PRIVATE_IMPORT_INCLUDES) \
+	$(shell cat $(PRIVATE_IMPORT_INCLUDES)) \
 	$(addprefix -isystem ,\
 	    $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
 	        $(filter-out $(PRIVATE_C_INCLUDES), \
@@ -975,7 +975,7 @@
 @echo "host C++: $(PRIVATE_MODULE) <= $<"
 $(hide) $(PRIVATE_CXX) \
 	$(addprefix -I , $(PRIVATE_C_INCLUDES)) \
-	@$(PRIVATE_IMPORT_INCLUDES) \
+	$(shell cat $(PRIVATE_IMPORT_INCLUDES)) \
 	$(addprefix -isystem ,\
 	    $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
 	        $(filter-out $(PRIVATE_C_INCLUDES), \
@@ -1003,7 +1003,7 @@
 @mkdir -p $(dir $@)
 $(hide) $(PRIVATE_CC) \
 	$(addprefix -I , $(PRIVATE_C_INCLUDES)) \
-	@$(PRIVATE_IMPORT_INCLUDES) \
+	$(shell cat $(PRIVATE_IMPORT_INCLUDES)) \
 	$(addprefix -isystem ,\
 	    $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
 	        $(filter-out $(PRIVATE_C_INCLUDES), \
diff --git a/core/dex_preopt.mk b/core/dex_preopt.mk
index 38982c0..4c51b10 100644
--- a/core/dex_preopt.mk
+++ b/core/dex_preopt.mk
@@ -4,7 +4,7 @@
 ####################################
 
 # TODO: replace it with device's BOOTCLASSPATH
-DEXPREOPT_BOOT_JARS := core:core-junit:bouncycastle:ext:framework:android.policy:services:apache-xml
+DEXPREOPT_BOOT_JARS := core:core-junit:bouncycastle:ext:framework:telephony-common:mms-common:android.policy:services:apache-xml
 DEXPREOPT_BOOT_JARS_MODULES := $(subst :, ,$(DEXPREOPT_BOOT_JARS))
 
 DEXPREOPT_BUILD_DIR := $(OUT_DIR)
diff --git a/core/dumpvar.mk b/core/dumpvar.mk
index 0f7dd8f..5298f35 100644
--- a/core/dumpvar.mk
+++ b/core/dumpvar.mk
@@ -10,16 +10,26 @@
 endif
 
 # Add the ARM toolchain bin dir if it actually exists
-ifneq ($(wildcard $(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-4.6/bin),)
-	# this should be copied to HOST_OUT_EXECUTABLES instead
-	ABP:=$(ABP):$(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-4.6/bin
-endif
+ifeq ($(TARGET_ARCH),arm)
+    ifneq ($(wildcard $(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-4.6/bin),)
+        # this should be copied to HOST_OUT_EXECUTABLES instead
+        ABP:=$(ABP):$(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-4.6/bin
+    endif
+else ifeq ($(TARGET_ARCH),x86)
 
 # Add the x86 toolchain bin dir if it actually exists
-ifneq ($(wildcard $(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/x86/i686-android-linux-4.4.3/bin),)
-	# this should be copied to HOST_OUT_EXECUTABLES instead
-	ABP:=$(ABP):$(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/x86/i686-android-linux-4.4.3/bin
+    ifneq ($(wildcard $(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/x86/i686-linux-android-4.6/bin),)
+        # this should be copied to HOST_OUT_EXECUTABLES instead
+        ABP:=$(ABP):$(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/x86/i686-linux-android-4.6/bin
+    endif
 endif
+
+# Add the mips toolchain bin dir if it actually exists
+ifneq ($(wildcard $(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/mips/mipsel-linux-android-4.6/bin),)
+    # this should be copied to HOST_OUT_EXECUTABLES instead
+    ABP:=$(ABP):$(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/mips/mipsel-linux-android-4.6/bin
+endif
+
 ANDROID_BUILD_PATHS := $(ABP)
 ANDROID_PREBUILTS := prebuilt/$(HOST_PREBUILT_TAG)
 ANDROID_GCC_PREBUILTS := prebuilts/gcc/$(HOST_PREBUILT_TAG)
diff --git a/core/envsetup.mk b/core/envsetup.mk
index 74e9100..ce222a9 100644
--- a/core/envsetup.mk
+++ b/core/envsetup.mk
@@ -33,7 +33,7 @@
 
 # ---------------------------------------------------------------
 # Set up configuration for host machine.  We don't do cross-
-# compiles except for arm, so the HOST is whatever we are
+# compiles except for arm/mips, so the HOST is whatever we are
 # running on
 
 UNAME := $(shell uname -sm)
@@ -124,13 +124,10 @@
 # Set up configuration for target machine.
 # The following must be set:
 # 		TARGET_OS = { linux }
-# 		TARGET_ARCH = { arm | x86 }
+# 		TARGET_ARCH = { arm | x86 | mips }
 
-
-ifeq ($(TARGET_ARCH),)
-TARGET_ARCH := arm
-endif
 TARGET_OS := linux
+# TARGET_ARCH should be set by BoardConfig.mk and will be checked later
 
 # the target build type defaults to release
 ifneq ($(TARGET_BUILD_TYPE),debug)
diff --git a/core/executable.mk b/core/executable.mk
index 6138adb..baebc3b 100644
--- a/core/executable.mk
+++ b/core/executable.mk
@@ -12,6 +12,18 @@
 LOCAL_MODULE_SUFFIX := $(TARGET_EXECUTABLE_SUFFIX)
 endif
 
+####################################################
+## Add profiling libraries if aprof is turned
+####################################################
+ifeq ($(strip $(LOCAL_ENABLE_APROF)),true)
+  ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE), true)
+    LOCAL_STATIC_LIBRARIES += libaprof libaprof_static libc libcutils
+  else
+    LOCAL_SHARED_LIBRARIES += libaprof libaprof_runtime libc
+  endif
+  LOCAL_WHOLE_STATIC_LIBRARIES += libaprof_aux
+endif
+
 include $(BUILD_SYSTEM)/dynamic_binary.mk
 
 ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
diff --git a/core/java.mk b/core/java.mk
index 4e33ef2..9a4f3a2 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -15,8 +15,11 @@
 
 # Make sure there's something to build.
 # It's possible to build a package that doesn't contain any classes.
-ifeq (,$(strip $(LOCAL_SRC_FILES)$(all_res_assets)$(LOCAL_STATIC_JAVA_LIBRARIES)))
-$(error $(LOCAL_PATH): Target java module does not define any source or resource files)
+# LOCAL_SOURCE_FILES_ALL_GENERATED is set only if the module does not have static source files,
+# but generated source files in its LOCAL_INTERMEDIATE_SOURCE_DIR.
+# You have to set up the dependency in some other way.
+ifeq (,$(strip $(LOCAL_SRC_FILES)$(all_res_assets)$(LOCAL_STATIC_JAVA_LIBRARIES))$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED)))
+$(warning $(LOCAL_PATH): Target java module does not define any source or resource files)
 endif
 
 LOCAL_NO_STANDARD_LIBRARIES:=$(strip $(LOCAL_NO_STANDARD_LIBRARIES))
@@ -232,7 +235,7 @@
 # If the module includes java code (i.e., it's not framework-res), compile it.
 full_classes_jar :=
 built_dex :=
-ifneq (,$(strip $(all_java_sources)$(full_static_java_libs)))
+ifneq (,$(strip $(all_java_sources)$(full_static_java_libs))$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED)))
 
 # If LOCAL_BUILT_MODULE_STEM wasn't overridden by our caller,
 # full_classes_jar will be the same module as LOCAL_BUILT_MODULE.
diff --git a/core/legacy_prebuilts.mk b/core/legacy_prebuilts.mk
index 0e33a64..0a5f6d1 100644
--- a/core/legacy_prebuilts.mk
+++ b/core/legacy_prebuilts.mk
@@ -103,7 +103,4 @@
 	ueventd.rc \
 	ueventd.stingray.rc \
 	vold.fstab \
-	wl1271.bin \
-	zoneinfo.dat \
-	zoneinfo.idx \
-	zoneinfo.version
+	wl1271.bin
diff --git a/core/llvm_config.mk b/core/llvm_config.mk
index bc90b95..4145028 100644
--- a/core/llvm_config.mk
+++ b/core/llvm_config.mk
@@ -41,12 +41,12 @@
 endif
 ifeq ($(TARGET_ARCH),x86)
   CLANG_CONFIG_EXTRA_CFLAGS += \
-    -target i686-android-linux \
+    -target i686-linux-android \
     -nostdlibinc \
-    -B$(TARGET_TOOLCHAIN_ROOT)/i686-android-linux/bin
+    -B$(TARGET_TOOLCHAIN_ROOT)/i686-linux-android/bin
   CLANG_CONFIG_EXTRA_LDFLAGS += \
-    -target i686-android-linux \
-    -B$(TARGET_TOOLCHAIN_ROOT)/i686-android-linux/bin
+    -target i686-linux-android \
+    -B$(TARGET_TOOLCHAIN_ROOT)/i686-linux-android/bin
   CLANG_CONFIG_UNKNOWN_CFLAGS += \
     -finline-limit=300 \
     -fno-inline-functions-called-once \
diff --git a/core/main.mk b/core/main.mk
index 407a529..6516fa6 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -84,7 +84,7 @@
 # be generated correctly
 include $(BUILD_SYSTEM)/cleanbuild.mk
 
-VERSION_CHECK_SEQUENCE_NUMBER := 2
+VERSION_CHECK_SEQUENCE_NUMBER := 3
 -include $(OUT_DIR)/versions_checked.mk
 ifneq ($(VERSION_CHECK_SEQUENCE_NUMBER),$(VERSIONS_CHECKED))
 
@@ -157,8 +157,44 @@
 $(error stop)
 endif
 
+ifeq (darwin,$(HOST_OS))
+GCC_REALPATH = $(realpath $(shell which gcc))
+ifneq ($(findstring llvm-gcc,$(GCC_REALPATH)),)
+  # Using LLVM GCC results in a non functional emulator due to it
+  # not honouring global register variables
+  $(warning ****************************************)
+  $(warning * gcc is linked to llvm-gcc which will *)
+  $(warning * not create a useable emulator.       *)
+  $(warning ****************************************)
+  BUILD_EMULATOR := false
+else
+  BUILD_EMULATOR := true
+endif
+# When building on Leopard or above, we need to use the 10.4 SDK
+# or the generated binary will not run on Tiger.
+darwin_version := $(strip $(shell sw_vers -productVersion))
+ifneq ($(filter 10.1 10.2 10.3 10.1.% 10.2.% 10.3.% 10.4 10.4.%,$(darwin_version)),)
+    $(error Building the Android emulator requires OS X 10.5 or above)
+endif
+ifneq ($(filter 10.5 10.5.% 10.6 10.6.%,$(darwin_version)),)
+    # We are on Leopard or Snow Leopard
+    MSDK=10.5
+else
+    # We are on Lion or beyond, and 10.6 SDK is the minimum in Xcode 4.x
+   MSDK=10.6
+endif
+MACOSX_SDK := /Developer/SDKs/MacOSX$(MSDK).sdk
+ifeq ($(strip $(wildcard $(MACOSX_SDK))),)
+  BUILD_EMULATOR := false
+endif
+else   # HOST_OS is not darwin
+  BUILD_EMULATOR := true
+endif  # HOST_OS is darwin
+
 $(shell echo 'VERSIONS_CHECKED := $(VERSION_CHECK_SEQUENCE_NUMBER)' \
         > $(OUT_DIR)/versions_checked.mk)
+$(shell echo 'BUILD_EMULATOR := $(BUILD_EMULATOR)' \
+        >> $(OUT_DIR)/versions_checked.mk)
 endif
 
 # These are the modifier targets that don't do anything themselves, but
@@ -236,6 +272,10 @@
 is_sdk_build := true
 endif
 
+## have selinux ##
+ifeq ($(HAVE_SELINUX),true)
+ADDITIONAL_BUILD_PROPERTIES += ro.build.selinux=1
+endif # HAVE_SELINUX
 
 ## user/userdebug ##
 
diff --git a/core/shared_library.mk b/core/shared_library.mk
index d715349..ab7480d 100644
--- a/core/shared_library.mk
+++ b/core/shared_library.mk
@@ -20,12 +20,25 @@
 $(error $(LOCAL_PATH): Can not set module stem for a library)
 endif
 
+####################################################
+## Add profiling libraries if aprof is turned
+####################################################
+ifeq ($(strip $(LOCAL_ENABLE_APROF_JNI)),true)
+  LOCAL_ENABLE_APROF := true
+  LOCAL_WHOLE_STATIC_LIBRARIES += libaprof_jni
+endif
+
+ifeq ($(strip $(LOCAL_ENABLE_APROF)),true)
+  LOCAL_SHARED_LIBRARIES += libaprof libaprof_runtime
+endif
+
 # Put the built targets of all shared libraries in a common directory
 # to simplify the link line.
 OVERRIDE_BUILT_MODULE_PATH := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)
 
 include $(BUILD_SYSTEM)/dynamic_binary.mk
 
+
 # Define PRIVATE_ variables from global vars
 my_target_global_ld_dirs := $(TARGET_GLOBAL_LD_DIRS)
 my_target_global_ldflags := $(TARGET_GLOBAL_LDFLAGS)
diff --git a/core/static_library.mk b/core/static_library.mk
index 66e091b..2a8edfd 100644
--- a/core/static_library.mk
+++ b/core/static_library.mk
@@ -18,6 +18,13 @@
 $(error $(LOCAL_PATH): Can not set module stem for a library)
 endif
 
+####################################################
+## Add profiling libraries if aprof is turned
+####################################################
+ifeq ($(strip $(LOCAL_ENABLE_APROF)),true)
+  LOCAL_WHOLE_STATIC_LIBRARIES += libaprof
+endif
+
 include $(BUILD_SYSTEM)/binary.mk
 
 ifeq ($(LOCAL_RAW_STATIC_LIBRARY),true)
diff --git a/core/user_tags.mk b/core/user_tags.mk
index 24f563d..e13969c 100644
--- a/core/user_tags.mk
+++ b/core/user_tags.mk
@@ -112,6 +112,7 @@
 	emmalib \
 	emulator \
 	emulator-arm \
+	emulator-mips \
 	emulator-core \
 	emulator-elff \
 	emulator-hw \
@@ -209,6 +210,7 @@
 	libebl \
 	libebl_arm \
 	libebl_sh \
+	libebl_mips \
 	libedify \
 	libeffects \
 	libEGL \
diff --git a/core/version_defaults.mk b/core/version_defaults.mk
index b3e3c6e..6ebfcef 100644
--- a/core/version_defaults.mk
+++ b/core/version_defaults.mk
@@ -41,7 +41,7 @@
   # which is the version that we reveal to the end user.
   # Update this value when the platform version changes (rather
   # than overriding it somewhere else).  Can be an arbitrary string.
-  PLATFORM_VERSION := 4.1.1
+  PLATFORM_VERSION := 4.0.9.99.999.9999.99999
 endif
 
 ifeq "" "$(PLATFORM_SDK_VERSION)"
@@ -59,7 +59,7 @@
 ifeq "" "$(PLATFORM_VERSION_CODENAME)"
   # This is the current development code-name, if the build is not a final
   # release build.  If this is a final release build, it is simply "REL".
-  PLATFORM_VERSION_CODENAME := REL
+  PLATFORM_VERSION_CODENAME := AOSP
 endif
 
 ifeq "" "$(DEFAULT_APP_TARGET_SDK)"
diff --git a/envsetup.sh b/envsetup.sh
index 8b7eea9..2da629d 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -118,10 +118,12 @@
     export ANDROID_EABI_TOOLCHAIN=
     local ARCH=$(get_build_var TARGET_ARCH)
     case $ARCH in
-        x86) toolchaindir=x86/i686-android-linux-4.4.3/bin
+        x86) toolchaindir=x86/i686-linux-android-4.6/bin
             ;;
         arm) toolchaindir=arm/arm-linux-androideabi-4.6/bin
             ;;
+        mips) toolchaindir=mips/mipsel-linux-android-4.6/bin
+            ;;
         *)
             echo "Can't find toolchain for unknown architecture: $ARCH"
             toolchaindir=xxxxxxxxx
@@ -131,25 +133,26 @@
         export ANDROID_EABI_TOOLCHAIN=$gccprebuiltdir/$toolchaindir
     fi
 
-    export ARM_EABI_TOOLCHAIN=
+    unset ARM_EABI_TOOLCHAIN ARM_EABI_TOOLCHAIN_PATH
     case $ARCH in
-        x86) toolchaindir=x86/i686-eabi-4.4.3/bin
+        arm)
+            toolchaindir=arm/arm-eabi-4.6/bin
+            if [ -d "$gccprebuiltdir/$toolchaindir" ]; then
+                 export ARM_EABI_TOOLCHAIN="$gccprebuiltdir/$toolchaindir"
+                 ARM_EABI_TOOLCHAIN_PATH=":$gccprebuiltdir/$toolchaindir"
+            fi
             ;;
-        arm) toolchaindir=arm/arm-eabi-4.6/bin
+        mips) toolchaindir=mips/mips-eabi-4.4.3/bin
             ;;
         *)
-            echo "Can't find toolchain for unknown architecture: $ARCH"
-            toolchaindir=xxxxxxxxx
+            # No need to set ARM_EABI_TOOLCHAIN for other ARCHs
             ;;
     esac
-    if [ -d "$gccprebuiltdir/$toolchaindir" ]; then
-        export ARM_EABI_TOOLCHAIN=$gccprebuiltdir/$toolchaindir
-    fi
 
     export ANDROID_TOOLCHAIN=$ANDROID_EABI_TOOLCHAIN
     export ANDROID_QTOOLS=$T/development/emulator/qtools
     export ANDROID_DEV_SCRIPTS=$T/development/scripts
-    export ANDROID_BUILD_PATHS=:$(get_build_var ANDROID_BUILD_PATHS):$ANDROID_QTOOLS:$ANDROID_TOOLCHAIN:$ARM_EABI_TOOLCHAIN$CODE_REVIEWS:$ANDROID_DEV_SCRIPTS
+    export ANDROID_BUILD_PATHS=:$(get_build_var ANDROID_BUILD_PATHS):$ANDROID_QTOOLS:$ANDROID_TOOLCHAIN$ARM_EABI_TOOLCHAIN_PATH$CODE_REVIEWS:$ANDROID_DEV_SCRIPTS
     export PATH=$PATH$ANDROID_BUILD_PATHS
 
     unset ANDROID_JAVA_TOOLCHAIN
@@ -204,13 +207,14 @@
 function settitle()
 {
     if [ "$STAY_OFF_MY_LAWN" = "" ]; then
+        local arch=$(gettargetarch)
         local product=$TARGET_PRODUCT
         local variant=$TARGET_BUILD_VARIANT
         local apps=$TARGET_BUILD_APPS
         if [ -z "$apps" ]; then
-            export PROMPT_COMMAND="echo -ne \"\033]0;[${product}-${variant}] ${USER}@${HOSTNAME}: ${PWD}\007\""
+            export PROMPT_COMMAND="echo -ne \"\033]0;[${arch}-${product}-${variant}] ${USER}@${HOSTNAME}: ${PWD}\007\""
         else
-            export PROMPT_COMMAND="echo -ne \"\033]0;[$apps $variant] ${USER}@${HOSTNAME}: ${PWD}\007\""
+            export PROMPT_COMMAND="echo -ne \"\033]0;[$arch $apps $variant] ${USER}@${HOSTNAME}: ${PWD}\007\""
         fi
     fi
 }
@@ -417,6 +421,7 @@
 add_lunch_combo full-eng
 add_lunch_combo full_x86-eng
 add_lunch_combo vbox_x86-eng
+add_lunch_combo full_mips-eng
 
 function print_lunch_menu()
 {
@@ -737,8 +742,9 @@
    local ARCH=$(get_build_var TARGET_ARCH)
    local GDB
    case "$ARCH" in
-       x86) GDB=i686-android-linux-gdb;;
+       x86) GDB=i686-linux-android-gdb;;
        arm) GDB=arm-linux-androideabi-gdb;;
+       mips) GDB=mipsel-linux-android-gdb;;
        *) echo "Unknown arch $ARCH"; return 1;;
    esac
 
@@ -805,6 +811,11 @@
         ;;
 esac
 
+function gettargetarch
+{
+    get_build_var TARGET_ARCH
+}
+
 function jgrep()
 {
     find . -name .repo -prune -o -name .git -prune -o  -type f -name "*\.java" -print0 | xargs -0 grep --color -n "$@"
@@ -860,7 +871,8 @@
         return
     fi
     local prebuiltdir=$(getprebuilt)
-    local KERNEL=$T/prebuilt/android-arm/kernel/vmlinux-qemu
+    local arch=$(gettargetarch)
+    local KERNEL=$T/prebuilts/qemu-kernel/$arch/vmlinux-qemu
 
     local TRACE=$1
     if [ ! "$TRACE" ] ; then
diff --git a/target/board/generic/BoardConfig.mk b/target/board/generic/BoardConfig.mk
index bc999fa..7a25f30 100644
--- a/target/board/generic/BoardConfig.mk
+++ b/target/board/generic/BoardConfig.mk
@@ -6,6 +6,7 @@
 # The generic product target doesn't have any hardware-specific pieces.
 TARGET_NO_BOOTLOADER := true
 TARGET_NO_KERNEL := true
+TARGET_ARCH := arm
 
 # Note: we build the platform images for ARMv7-A _without_ NEON.
 #
@@ -29,13 +30,12 @@
 # no hardware camera
 USE_CAMERA_STUB := true
 
-# Set /system/bin/sh to ash, not mksh, to make sure we can switch back.
-TARGET_SHELL := ash
-
 # Enable dex-preoptimization to speed up the first boot sequence
 # of an SDK AVD. Note that this operation only works on Linux for now
 ifeq ($(HOST_OS),linux)
-WITH_DEXPREOPT := true
+  ifeq ($(WITH_DEXPREOPT),)
+    WITH_DEXPREOPT := true
+  endif
 endif
 
 # Build OpenGLES emulation guest and host libraries
diff --git a/target/board/generic_mips/Android.mk b/target/board/generic_mips/Android.mk
new file mode 100644
index 0000000..abf8d57
--- /dev/null
+++ b/target/board/generic_mips/Android.mk
@@ -0,0 +1,17 @@
+#
+# Copyright (C) 2011 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.
+#
+
+LOCAL_PATH := $(call my-dir)
diff --git a/target/board/generic_mips/BoardConfig.mk b/target/board/generic_mips/BoardConfig.mk
new file mode 100644
index 0000000..8c2371f
--- /dev/null
+++ b/target/board/generic_mips/BoardConfig.mk
@@ -0,0 +1,53 @@
+#
+# Copyright (C) 2011 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.
+#
+# BoardConfig.mk
+#
+# Product-specific compile-time definitions.
+#
+
+# The generic product target doesn't have any hardware-specific pieces.
+TARGET_NO_BOOTLOADER := true
+TARGET_NO_KERNEL := true
+
+TARGET_ARCH := mips
+ifeq (,$(TARGET_ARCH_VARIANT))
+TARGET_ARCH_VARIANT := mips32r2-fp
+endif
+TARGET_CPU_ABI  := mips
+
+HAVE_HTC_AUDIO_DRIVER := true
+BOARD_USES_GENERIC_AUDIO := true
+
+# no hardware camera
+USE_CAMERA_STUB := true
+
+# Set /system/bin/sh to ash, not mksh, to make sure we can switch back.
+TARGET_SHELL := ash
+
+# Enable dex-preoptimization to speed up the first boot sequence
+# of an SDK AVD. Note that this operation only works on Linux for now
+ifeq ($(HOST_OS),linux)
+  ifeq ($(WITH_DEXPREOPT),)
+    WITH_DEXPREOPT := true
+  endif
+endif
+
+# Build OpenGLES emulation guest and host libraries
+BUILD_EMULATOR_OPENGL := true
+
+# Build and enable the OpenGL ES View renderer. When running on the emulator,
+# the GLES renderer disables itself if host GL acceleration isn't available.
+USE_OPENGL_RENDERER := true
diff --git a/target/board/generic_mips/README.txt b/target/board/generic_mips/README.txt
new file mode 100644
index 0000000..b31a857
--- /dev/null
+++ b/target/board/generic_mips/README.txt
@@ -0,0 +1,9 @@
+The "generic_mips" product defines a MIPS based non-hardware-specific
+target without a kernel or bootloader.
+
+It can be used to build the entire user-level system, and
+will work with the emulator, though sound will not work
+(see the "emulator" product for that).
+
+It is not a product "base class"; no other products inherit
+from it or use it in any way.
diff --git a/target/board/generic_mips/device.mk b/target/board/generic_mips/device.mk
new file mode 100644
index 0000000..8c770b5
--- /dev/null
+++ b/target/board/generic_mips/device.mk
@@ -0,0 +1,35 @@
+#
+# Copyright (C) 2009 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.
+#
+
+# This is a build configuration for the product aspects that
+# are specific to the emulator.
+
+PRODUCT_PROPERTY_OVERRIDES := \
+    ro.ril.hsxpa=1 \
+    ro.ril.gprsclass=10 \
+    ro.adb.qemud=1
+
+PRODUCT_COPY_FILES := \
+    device/generic/goldfish/data/etc/apns-conf.xml:system/etc/apns-conf.xml \
+    device/generic/goldfish/data/etc/vold.conf:system/etc/vold.conf \
+    $(call add-to-product-copy-files-if-exists,development/tools/emulator/system/camera/media_profiles.xml:system/etc/media_profiles.xml) \
+    $(call add-to-product-copy-files-if-exists,development/tools/emulator/system/camera/media_codecs.xml:system/etc/media_codecs.xml) \
+    hardware/libhardware_legacy/audio/audio_policy.conf:system/etc/audio_policy.conf
+
+PRODUCT_PACKAGES := \
+    audio.primary.goldfish \
+    power.goldfish \
+    libffi
diff --git a/target/board/generic_mips/system.prop b/target/board/generic_mips/system.prop
new file mode 100644
index 0000000..137a0f9
--- /dev/null
+++ b/target/board/generic_mips/system.prop
@@ -0,0 +1,6 @@
+#
+# system.prop for generic sdk
+#
+
+rild.libpath=/system/lib/libreference-ril.so
+rild.libargs=-d /dev/ttyS0
diff --git a/target/board/generic_x86/BoardConfig.mk b/target/board/generic_x86/BoardConfig.mk
index c62b0a4..4a9e5fe 100644
--- a/target/board/generic_x86/BoardConfig.mk
+++ b/target/board/generic_x86/BoardConfig.mk
@@ -8,7 +8,7 @@
 TARGET_NO_KERNEL := true
 TARGET_CPU_ABI := x86
 TARGET_ARCH := x86
-TARGET_ARCH_VARIANT := x86-atom
+TARGET_ARCH_VARIANT := x86
 TARGET_PRELINK_MODULE := false
 
 # The IA emulator (qemu) uses the Goldfish devices
@@ -18,8 +18,8 @@
 # no hardware camera
 USE_CAMERA_STUB := true
 
-# Set /system/bin/sh to ash, not mksh, to make sure we can switch back.
-TARGET_SHELL := ash
+# customize the malloced address to be 16-byte aligned
+BOARD_MALLOC_ALIGNMENT := 16
 
 # Enable dex-preoptimization to speed up the first boot sequence
 # of an SDK AVD. Note that this operation only works on Linux for now
diff --git a/target/board/vbox_x86/BoardConfig.mk b/target/board/vbox_x86/BoardConfig.mk
index dc0f19e..80a9077 100644
--- a/target/board/vbox_x86/BoardConfig.mk
+++ b/target/board/vbox_x86/BoardConfig.mk
@@ -37,3 +37,5 @@
 # The eth0 device should be started with dhcp on boot.
 # Useful for emulators that don't provide a wifi connection.
 NET_ETH0_STARTONBOOT := true
+
+ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.heapsize=32m
diff --git a/target/product/AndroidProducts.mk b/target/product/AndroidProducts.mk
index 44b9000..9279633 100644
--- a/target/product/AndroidProducts.mk
+++ b/target/product/AndroidProducts.mk
@@ -36,10 +36,13 @@
     $(LOCAL_DIR)/core.mk \
     $(LOCAL_DIR)/generic.mk \
     $(LOCAL_DIR)/generic_x86.mk \
+    $(LOCAL_DIR)/generic_mips.mk \
     $(LOCAL_DIR)/full.mk \
     $(LOCAL_DIR)/full_x86.mk \
+    $(LOCAL_DIR)/full_mips.mk \
     $(LOCAL_DIR)/vbox_x86.mk \
     $(LOCAL_DIR)/sdk.mk \
     $(LOCAL_DIR)/sdk_x86.mk \
+    $(LOCAL_DIR)/sdk_mips.mk \
     $(LOCAL_DIR)/large_emu_hw.mk
 endif
diff --git a/target/product/core.mk b/target/product/core.mk
index 688c806..d637bd4 100644
--- a/target/product/core.mk
+++ b/target/product/core.mk
@@ -119,7 +119,12 @@
     screencap \
     sensorservice \
     lint \
-    uiautomator
+    uiautomator \
+    telephony-common \
+    mms-common \
+    zoneinfo.dat \
+    zoneinfo.idx \
+    zoneinfo.version
 
 PRODUCT_COPY_FILES += \
     system/core/rootdir/init.usb.rc:root/init.usb.rc \
@@ -138,5 +143,17 @@
         libjavacore \
         libssl \
         libz-host \
-        dalvik
+        dalvik \
+        zoneinfo-host.dat \
+        zoneinfo-host.idx \
+        zoneinfo-host.version
+endif
+
+ifeq ($(HAVE_SELINUX),true)
+    PRODUCT_PACKAGES += \
+        sepolicy \
+        file_contexts \
+        seapp_contexts \
+        property_contexts \
+        mac_permissions.xml
 endif
diff --git a/target/product/full_base.mk b/target/product/full_base.mk
index 6a702da..2c24b1a 100644
--- a/target/product/full_base.mk
+++ b/target/product/full_base.mk
@@ -20,9 +20,6 @@
 # in inherited configurations.
 
 PRODUCT_PACKAGES := \
-    drmserver \
-    libdrmframework \
-    libdrmframework_jni \
     libfwdlockengine \
     OpenWnn \
     PinyinIME \
diff --git a/target/product/full_mips.mk b/target/product/full_mips.mk
new file mode 100644
index 0000000..2debfec
--- /dev/null
+++ b/target/product/full_mips.mk
@@ -0,0 +1,29 @@
+#
+# Copyright (C) 2009 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.
+#
+
+# This is a build configuration for a full-featured build of the
+# Open-Source part of the tree. It's geared toward a US-centric
+# mips build quite specifically for the emulator, and might not be
+# entirely appropriate to inherit from for on-device configurations.
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base_telephony.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/board/generic_mips/device.mk)
+
+# Overrides
+PRODUCT_NAME := full_mips
+PRODUCT_DEVICE := generic_mips
+PRODUCT_BRAND := Android
+PRODUCT_MODEL := Full MIPS Android on Emulator
diff --git a/target/product/full_x86.mk b/target/product/full_x86.mk
index d6a169a..9941384 100644
--- a/target/product/full_x86.mk
+++ b/target/product/full_x86.mk
@@ -22,13 +22,14 @@
 # If running on an emulator or some other device that has a LAN connection
 # that isn't a wifi connection. This will instruct init.rc to enable the
 # network connection so that you can use it with ADB
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base_telephony.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/board/generic_x86/device.mk)
+
 ifdef NET_ETH0_STARTONBOOT
   PRODUCT_PROPERTY_OVERRIDES += net.eth0.startonboot=1
 endif
 
-$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base.mk)
-$(call inherit-product, $(SRC_TARGET_DIR)/board/generic_x86/device.mk)
-
 # Ensure we package the BIOS files too.
 PRODUCT_PACKAGES += \
 	bios.bin \
diff --git a/target/product/generic_mips.mk b/target/product/generic_mips.mk
new file mode 100644
index 0000000..7b53d04
--- /dev/null
+++ b/target/product/generic_mips.mk
@@ -0,0 +1,26 @@
+#
+# Copyright (C) 2007 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.
+#
+
+# This is a generic phone product that isn't specialized for a specific device.
+# It includes the base Android platform.
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic_no_telephony.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/telephony.mk)
+
+# Overrides
+PRODUCT_BRAND := generic_mips
+PRODUCT_DEVICE := generic_mips
+PRODUCT_NAME := generic_mips
diff --git a/target/product/generic_x86.mk b/target/product/generic_x86.mk
index 86710c4..0274b5b 100644
--- a/target/product/generic_x86.mk
+++ b/target/product/generic_x86.mk
@@ -14,10 +14,10 @@
 # limitations under the License.
 #
 
-# This is a generic product that isn't specialized for a specific device.
+# This is a generic phone product that isn't specialized for a specific device.
 # It includes the base Android platform.
 
-$(call inherit-product, $(SRC_TARGET_DIR)/product/generic.mk)
+include $(SRC_TARGET_DIR)/product/generic.mk
 
 # Overrides
 PRODUCT_BRAND := generic_x86
diff --git a/target/product/locales_full.mk b/target/product/locales_full.mk
index 8b8ab05..3a90d2b 100644
--- a/target/product/locales_full.mk
+++ b/target/product/locales_full.mk
@@ -1,3 +1,3 @@
-PRODUCT_LOCALES := en_US cs_CZ da_DK de_AT de_CH de_DE de_LI el_GR en_AU en_CA en_GB en_NZ en_SG es_ES fr_CA fr_CH fr_BE fr_FR it_CH it_IT ja_JP ko_KR nb_NO nl_BE nl_NL pl_PL pt_PT ru_RU sv_SE tr_TR zh_CN zh_HK zh_TW am_ET hi_IN
+PRODUCT_LOCALES := en_US cs_CZ da_DK de_AT de_CH de_DE de_LI el_GR en_AU en_CA en_GB en_NZ en_SG eo_EU es_ES fr_CA fr_CH fr_BE fr_FR it_CH it_IT ja_JP ko_KR nb_NO nl_BE nl_NL pl_PL pt_PT ru_RU sv_SE tr_TR zh_CN zh_HK zh_TW am_ET hi_IN
 
 $(call inherit-product, build/target/product/languages_full.mk)
diff --git a/target/product/sdk.mk b/target/product/sdk.mk
index 6165f71..697d295 100644
--- a/target/product/sdk.mk
+++ b/target/product/sdk.mk
@@ -89,6 +89,7 @@
 	development/tools/emulator/system/camera/media_codecs.xml:system/etc/media_codecs.xml \
 	frameworks/native/data/etc/android.hardware.touchscreen.multitouch.jazzhand.xml:system/etc/permissions/android.hardware.touchscreen.multitouch.jazzhand.xml \
 	frameworks/native/data/etc/android.hardware.camera.autofocus.xml:system/etc/permissions/android.hardware.camera.autofocus.xml \
+	frameworks/av/media/libeffects/data/audio_effects.conf:system/etc/audio_effects.conf \
 	hardware/libhardware_legacy/audio/audio_policy.conf:system/etc/audio_policy.conf
 
 $(call inherit-product-if-exists, frameworks/base/data/fonts/fonts.mk)
diff --git a/target/product/sdk_mips.mk b/target/product/sdk_mips.mk
new file mode 100644
index 0000000..2072400
--- /dev/null
+++ b/target/product/sdk_mips.mk
@@ -0,0 +1,28 @@
+#
+# Copyright (C) 2012 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.
+#
+
+# This is a build configuration for a full-featured build of the
+# Open-Source part of the tree. It's geared toward a US-centric
+# build quite specifically for the emulator, and might not be
+# entirely appropriate to inherit from for on-device configurations.
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/sdk.mk)
+
+# Overrides
+PRODUCT_BRAND := generic_mips
+PRODUCT_NAME := sdk_mips
+PRODUCT_DEVICE := generic_mips
+PRODUCT_MODEL := Android SDK for Mips
diff --git a/target/product/sdk_x86.mk b/target/product/sdk_x86.mk
index 6c5e746..873d0c0 100644
--- a/target/product/sdk_x86.mk
+++ b/target/product/sdk_x86.mk
@@ -19,7 +19,7 @@
 # build quite specifically for the emulator, and might not be
 # entirely appropriate to inherit from for on-device configurations.
 
-$(call inherit-product, $(SRC_TARGET_DIR)/product/sdk.mk)
+include $(SRC_TARGET_DIR)/product/sdk.mk
 
 # Overrides
 PRODUCT_BRAND := generic_x86
diff --git a/tools/atree/fs.cpp b/tools/atree/fs.cpp
index b648394..9468cfd 100644
--- a/tools/atree/fs.cpp
+++ b/tools/atree/fs.cpp
@@ -152,8 +152,8 @@
 int
 strip_file(const string& path)
 {
-    // Default strip command to run is "strip" unless overridden by the STRIP env var.
-    const char* strip_cmd = getenv("STRIP");
+    // Default strip command to run is "strip" unless overridden by the ATREE_STRIP env var.
+    const char* strip_cmd = getenv("ATREE_STRIP");
     if (!strip_cmd || !strip_cmd[0]) {
         strip_cmd = "strip";
     }
@@ -163,7 +163,52 @@
         return -1;
     } else if (pid == 0) {
         // Exec in the child. Only returns if execve failed.
-        return execlp(strip_cmd, strip_cmd, path.c_str(), (char *)NULL);
+
+        int num_args = 0;
+        const char *s = strip_cmd;
+        while (*s) {
+            while (*s == ' ') ++s;
+            if (*s && *s != ' ') {
+                ++num_args;
+                while (*s && *s != ' ') ++s;
+            }
+        }
+
+        if (num_args <= 0) {
+            fprintf(stderr, "Invalid ATREE_STRIP command '%s'\n", strip_cmd);
+            return 1;
+
+        } else if (num_args == 1) {
+            return execlp(strip_cmd, strip_cmd, path.c_str(), (char *)NULL);
+
+        } else {
+            // Split the arguments if more than 1
+            char* cmd = strdup(strip_cmd);
+            const char** args = (const char**) malloc(sizeof(const char*) * (num_args + 2));
+
+            const char** curr = args;
+            char* s = cmd;
+            while (*s) {
+                while (*s == ' ') ++s;
+                if (*s && *s != ' ') {
+                    *curr = s;
+                    ++curr;
+                    while (*s && *s != ' ') ++s;
+                    if (*s) {
+                        *s = '\0';
+                        ++s;
+                    }
+                }
+            }
+
+            args[num_args] = path.c_str();
+            args[num_args + 1] = NULL;
+
+            int ret = execvp(args[0], (char* const*)args);
+            free(args);
+            free(cmd);
+            return ret;
+        }
     } else {
         // Wait for child pid and return its exit code.
         int status;
diff --git a/tools/droiddoc/templates-sdk/assets/css/default.css b/tools/droiddoc/templates-sdk/assets/css/default.css
index 2513e69..f11daf7 100644
--- a/tools/droiddoc/templates-sdk/assets/css/default.css
+++ b/tools/droiddoc/templates-sdk/assets/css/default.css
@@ -530,12 +530,12 @@
 }
 .design ol {
   counter-reset: item; }
-  .design ol li {
+  .design ol>li {
     font-size: 14px;
     line-height: 20px;
     list-style-type: none;
     position: relative; }
-    .design ol li:before {
+    .design ol>li:before {
       content: counter(item) ". ";
       counter-increment: item;
       position: absolute;
@@ -561,16 +561,18 @@
       content: "9. "; }
     .design ol li.value-10:before {
       content: "10. "; }
-.design .with-callouts ol li {
+.design .with-callouts ol>li {
   list-style-position: inside;
   margin-left: 0; }
-  .design .with-callouts ol li:before {
+  .design .with-callouts ol>li:before {
     display: inline;
     left: -20px;
     float: left;
     width: 17px;
     color: #33b5e5;
     font-weight: 500; }
+.design .with-callouts ul>li {
+  list-style-position: outside; }
 
 /* special list items */
 li.no-bullet {
@@ -1079,22 +1081,71 @@
    Print Only
    ========================================================================== */
 @media print {
-a {
-    color: inherit;
-}
-.nav-x, .nav-y {
-    display: none;
-}
-.str { color: #060; }
-.kwd { color: #006; font-weight: bold; }
-.com { color: #600; font-style: italic; }
-.typ { color: #404; font-weight: bold; }
-.lit { color: #044; }
-.pun { color: #440; }
-.pln { color: #000; }
-.tag { color: #006; font-weight: bold; }
-.atn { color: #404; }
-.atv { color: #060; }
+  /* configure printed page */
+  @page {
+      margin: 0.75in 1in;
+      widows: 4;
+      orphans: 4;
+  }
+
+  /* reset spacing metrics */
+  html, body, .wrap {
+      margin: 0 !important;
+      padding: 0 !important;
+      width: auto !important;
+  }
+
+  /* leave enough space on the left for bullets */
+  body {
+      padding-left: 20px !important;
+  }
+  #doc-col {
+      margin-left: 0;
+  }
+
+  /* hide a bunch of non-content elements */
+  #header, #footer, #nav-x, #side-nav,
+  .training-nav-top, .training-nav-bottom,
+  #doc-col .content-footer,
+  .nav-x, .nav-y,
+  .paging-links,
+  a.totop {
+      display: none !important;
+  }
+
+  /* remove extra space above page titles */
+  #doc-col .content-header {
+      margin-top: 0;
+  }
+
+  /* bump up spacing above subheadings */
+  h2 {
+      margin-top: 40px !important;
+  }
+
+  /* print link URLs where possible and give links default text color */
+  p a:after {
+      content: " (" attr(href) ")";
+      font-size: 80%;
+  }
+  p a {
+      word-wrap: break-word;
+  }
+  a {
+      color: inherit;
+  }
+
+  /* syntax highlighting rules */
+  .str { color: #060; }
+  .kwd { color: #006; font-weight: bold; }
+  .com { color: #600; font-style: italic; }
+  .typ { color: #404; font-weight: bold; }
+  .lit { color: #044; }
+  .pun { color: #440; }
+  .pln { color: #000; }
+  .tag { color: #006; font-weight: bold; }
+  .atn { color: #404; }
+  .atv { color: #060; }
 }
 
 /* =============================================================================
@@ -2033,8 +2084,11 @@
 #jd-content img.toggle-content-img {
   margin:0 5px 5px 0;
 }
-div.toggle-content > p {
-  padding:0 0 5px;
+div.toggle-content p {
+  margin:10px 0 0;
+}
+div.toggle-content-toggleme {
+  padding:0 0 0 15px;
 }
 
 
@@ -2145,14 +2199,9 @@
 
 .nolist {
   list-style:none;
-  padding:0;
-  margin:0 0 1em 1em;
+  margin-left:0;
 }
 
-.nolist li {
-  padding:0 0 2px;
-  margin:0;
-}
 
 pre.classic {
   background-color:transparent;
@@ -2180,6 +2229,12 @@
   color:#666;
 }
 
+div.note, 
+div.caution, 
+div.warning {
+  margin: 0 0 15px;
+}
+
 p.note, div.note, 
 p.caution, div.caution, 
 p.warning, div.warning {
@@ -2898,10 +2953,6 @@
 
 /* SEARCH RESULTS */
 
-/* disable twiddle and size selectors for left column */
-#leftSearchControl div {
-  padding:0;
-}
 
 #leftSearchControl .gsc-twiddle {
   background-image : none;
@@ -3475,7 +3526,7 @@
 
 .morehover:hover {
   opacity:1;
-  height:345px;
+  height:385px;
   width:268px;
   -webkit-transition-property:height,  -webkit-opacity;
 }
@@ -3489,7 +3540,7 @@
 .morehover .mid {
   width:228px;
   background:url(../images/more_mid.png) repeat-y;
-  padding:10px 20px 10px 20px;
+  padding:10px 20px 0 20px;
 }
 
 .morehover .mid .header {
@@ -3598,15 +3649,19 @@
   padding-top: 14px;
 }
 
+#nav-x .wrap {
+  min-height:34px;
+}
+
 #nav-x .wrap,
 #searchResults.wrap {
     max-width:940px;
     border-bottom:1px solid #CCC;
-    min-height:34px;
-    
 }
 
-
+#searchResults.wrap #leftSearchControl {
+  min-height:700px
+}
 .nav-x {
     margin-left:0;
     margin-bottom:0;
@@ -3762,7 +3817,8 @@
   height: 300px;
 }
 .slideshow-develop img.play {
-  width:350px;
+  max-width:350px;
+  max-height:240px;
   margin:20px 0 0 90px;
   -webkit-transform: perspective(800px ) rotateY( 35deg );
   box-shadow: -16px 20px 40px rgba(0, 0, 0, 0.3);
@@ -3817,6 +3873,7 @@
 .feed .feed-nav li {
   list-style: none;
   float: left;
+  height: 21px; /* +4px bottom border = 25px; same as .feed-nav */
   margin-right: 25px;
   cursor: pointer;
 }
@@ -3969,21 +4026,24 @@
 .landing-docs {
   margin:20px 0 0;
 }
-.landing-banner {
-  height:280px;
-}
 .landing-banner .col-6:first-child,
-.landing-docs .col-6:first-child {
+.landing-docs .col-6:first-child,
+.landing-docs .col-12 {
   margin-left:0;
+  min-height:280px;
 }
 .landing-banner .col-6:last-child,
-.landing-docs .col-6:last-child {
+.landing-docs .col-6:last-child,
+.landing-docs .col-12 {
   margin-right:0;
 }
 
 .landing-banner h1 {
   margin-top:0;
 }
+.landing-docs {
+  clear:left;
+}
 .landing-docs h3 {
   font-size:14px;
   line-height:21px;
@@ -4002,4 +4062,99 @@
 
 .plusone {
   float:right;
-}
\ No newline at end of file
+}
+
+
+
+/************* HOME/LANDING PAGE *****************/
+
+.slideshow-home {
+  height: 500px;
+  width: 940px;
+  border-bottom: 1px solid #CCC;
+  position: relative;
+  margin: 0;
+}
+.slideshow-home .frame {
+  width: 940px;
+  height: 500px;
+}
+.slideshow-home .content-left {
+  float: left;
+  text-align: center;
+  vertical-align: center;
+  margin: 0 0 0 35px;
+}
+.slideshow-home .content-right {
+  margin: 80px 0 0 0;
+}
+.slideshow-home .content-right p {
+  margin-bottom: 10px;
+}
+.slideshow-home .content-right p:last-child {
+  margin-top: 15px;
+}
+.slideshow-home .content-right h1 {
+  padding:0;
+}
+.slideshow-home .item {
+  height: 500px;
+  width: 940px;
+}
+.home-sections {
+  padding: 30px 20px 20px;
+  margin: 20px 0;
+  background: -webkit-linear-gradient(top, #F6F6F6,#F9F9F9);
+}
+.home-sections ul {
+  margin: 0;
+}
+.home-sections ul li {
+  float: left;
+  display: block;
+  list-style: none;
+  width: 170px;
+  height: 35px;
+  border: 1px solid #ccc;
+  background: white;
+  margin-right: 10px;
+  border-radius: 1px;
+  -webkit-border-radius: 1px;
+  -moz-border-radius: 1px;
+  box-shadow: 1px 1px 5px #EEE;
+  -webkit-box-shadow: 1px 1px 5px #EEE;
+  -moz-box-shadow: 1px 1px 5px #EEE;
+  background: white;
+}
+.home-sections ul li:hover {
+  background: #F9F9F9;
+  border: 1px solid #CCC;
+}
+.home-sections ul li a,
+.home-sections ul li a:hover {
+  font-weight: bold;
+  margin-top: 8px;
+  line-height: 18px;
+  float: left;
+  width: 100%;
+  text-align: center;
+  color: #09c !important;
+}
+.home-sections ul li a {
+  font-weight: bold;
+  margin-top: 8px;
+  line-height: 18px;
+  float: left;
+  width:100%;
+  text-align:center;
+}
+.home-sections ul li img {
+  float: left;
+  margin: -8px 0 0 10px;
+}
+.home-sections ul li.last {
+  margin-right: 0px;
+}
+#footer {
+  margin-top: -40px;
+}
diff --git a/tools/droiddoc/templates-sdk/assets/css/fullscreen.css b/tools/droiddoc/templates-sdk/assets/css/fullscreen.css
index 7503924..71cf65b 100644
--- a/tools/droiddoc/templates-sdk/assets/css/fullscreen.css
+++ b/tools/droiddoc/templates-sdk/assets/css/fullscreen.css
@@ -2,6 +2,7 @@
 /* =============================================================================
    Columns
    ========================================================================== */
+/* Applied to body to debug layout alignments
 .grid {
   width:100%;
   height:100%;
@@ -10,6 +11,7 @@
   margin:auto;
   position:absolute;
 }   
+*/
 
 @media screen, projection, print {
 .full {
diff --git a/tools/droiddoc/templates-sdk/assets/css/home.css b/tools/droiddoc/templates-sdk/assets/css/home.css
deleted file mode 100644
index 5b7e048..0000000
--- a/tools/droiddoc/templates-sdk/assets/css/home.css
+++ /dev/null
@@ -1,90 +0,0 @@
-.slideshow-home {
-  height: 500px;
-  width: 940px;
-  border-bottom: 1px solid #CCC;
-  position: relative;
-  margin: 0;
-}
-.slideshow-home .frame {
-  width: 940px;
-  height: 500px;
-}
-.slideshow-home .content-left {
-  float: left;
-  text-align: center;
-  vertical-align: center;
-  margin: 0 0 0 35px;
-}
-.slideshow-home .content-right {
-  margin: 80px 0 0 0;
-}
-.slideshow-home .content-right p {
-  margin-bottom: 10px;
-}
-.slideshow-home .content-right p:last-child {
-  margin-top: 15px;
-}
-.slideshow-home .content-right h1 {
-  padding:0;
-}
-.slideshow-home .item {
-  height: 500px;
-  width: 940px;
-}
-.home-sections {
-  padding: 30px 20px 20px;
-  margin: 20px 0;
-  background: -webkit-linear-gradient(top, #F6F6F6,#F9F9F9);
-}
-.home-sections ul {
-  margin: 0;
-}
-.home-sections ul li {
-  float: left;
-  display: block;
-  list-style: none;
-  width: 170px;
-  height: 35px;
-  border: 1px solid #ccc;
-  background: white;
-  margin-right: 10px;
-  border-radius: 1px;
-  -webkit-border-radius: 1px;
-  -moz-border-radius: 1px;
-  box-shadow: 1px 1px 5px #EEE;
-  -webkit-box-shadow: 1px 1px 5px #EEE;
-  -moz-box-shadow: 1px 1px 5px #EEE;
-  background: white;
-}
-.home-sections ul li:hover {
-  background: #F9F9F9;
-  border: 1px solid #CCC;
-}
-.home-sections ul li a,
-.home-sections ul li a:hover {
-  font-weight: bold;
-  margin-top: 8px;
-  line-height: 18px;
-  float: left;
-  width: 100%;
-  text-align: center;
-  color: #09c !important;
-}
-.home-sections ul li a {
-  font-weight: bold;
-  margin-top: 8px;
-  line-height: 18px;
-  float: left;
-  width:100%;
-  text-align:center;
-}
-.home-sections ul li img {
-  float: left;
-  margin: -8px 0 0 10px;
-}
-.home-sections ul li.last {
-  margin-right: 0px;
-}
-#footer {
-  margin-top: -40px;
-}
\ No newline at end of file
diff --git a/tools/droiddoc/templates-sdk/assets/js/docs.js b/tools/droiddoc/templates-sdk/assets/js/docs.js
index 0b0a375..ba32d25 100644
--- a/tools/droiddoc/templates-sdk/assets/js/docs.js
+++ b/tools/droiddoc/templates-sdk/assets/js/docs.js
@@ -5,9 +5,11 @@
 var NAV_PREF_TREE = "tree";
 var NAV_PREF_PANELS = "panels";
 var nav_pref;
-var toRoot;
 var isMobile = false; // true if mobile, so we can adjust some layout
 
+var basePath = getBaseUri(location.pathname);
+var SITE_ROOT = toRoot + basePath.substring(1,basePath.indexOf("/",1));
+  
 
 /******  ON LOAD SET UP STUFF *********/
 
@@ -30,7 +32,7 @@
   
   // set search's onkeyup handler here so we can show suggestions 
   // even while search results are visible
-  $("#search_autocomplete").keyup(function() {return search_changed(event, false, '/')});
+  $("#search_autocomplete").keyup(function() {return search_changed(event, false, toRoot)});
 
   // set up the search close button
   $('.search .close').click(function() {
@@ -193,11 +195,15 @@
     
     if ($selListItem.hasClass('nav-section')) {
       // we're on an index page, jump to the first topic
-      $nextLink = $selListItem.find('ul').find('a:eq(0)');
+      $nextLink = $selListItem.find('ul:eq(0)').find('a:eq(0)');
 
       // if there aren't any children, go to the next section (required for About pages)
       if($nextLink.length == 0) {
         $nextLink = $selListItem.next('li').find('a');
+      } else if ($('.topic-start-link').length) {
+        // as long as there's a child link and there is a "topic start link" (we're on a landing)
+        // then set the landing page "start link" text to be the first doc title
+        $('.topic-start-link').text($nextLink.text().toUpperCase());
       }
       
       // Handle some Training specialties
@@ -526,11 +532,6 @@
   prettyPrint();
 } );
 
-function setToRoot(root) {
-  toRoot = root;
-  // note: toRoot also used by carousel.js
-}
-
 function init() {
   //resizeNav();
 
diff --git a/tools/droiddoc/templates-sdk/assets/js/search_autocomplete.js b/tools/droiddoc/templates-sdk/assets/js/search_autocomplete.js
index 1838ccb..04f0e93 100644
--- a/tools/droiddoc/templates-sdk/assets/js/search_autocomplete.js
+++ b/tools/droiddoc/templates-sdk/assets/js/search_autocomplete.js
@@ -1,82 +1,12 @@
-/**
- * jQuery history event v0.1
- * Copyright (c) 2008 Tom Rodenberg <tarodenberg gmail com>
- * Licensed under the GPL (http://www.gnu.org/licenses/gpl.html) license.
+/*
+ * jQuery hashchange event - v1.3 - 7/21/2010
+ * http://benalman.com/projects/jquery-hashchange-plugin/
+ * 
+ * Copyright (c) 2010 "Cowboy" Ben Alman
+ * Dual licensed under the MIT and GPL licenses.
+ * http://benalman.com/about/license/
  */
-(function($) {
-    var currentHash, previousNav, timer, hashTrim = /^.*#/;
-
-    var msie = {
-        iframe: null,
-        getDoc: function() {
-            return msie.iframe.contentWindow.document;
-        },
-        getHash: function() {
-            return msie.getDoc().location.hash;
-        },
-        setHash: function(hash) {
-            var d = msie.getDoc();
-            d.open();
-            d.close();
-            d.location.hash = hash;
-        }
-    };
-
-    var historycheck = function() {
-        var hash = msie.iframe ? msie.getHash() : location.hash;
-        if (hash != currentHash) {
-            currentHash = hash;
-            if (msie.iframe) {
-                location.hash = currentHash;
-            }
-            var current = $.history.getCurrent();
-            $.event.trigger('history', [current, previousNav]);
-            previousNav = current;
-        }
-    };
-
-    $.history = {
-        add: function(hash) {
-            hash = '#' + hash.replace(hashTrim, '');
-            if (currentHash != hash) {
-                var previous = $.history.getCurrent();
-                location.hash = currentHash = hash;
-                if (msie.iframe) {
-                    msie.setHash(currentHash);
-                }
-                $.event.trigger('historyadd', [$.history.getCurrent(), previous]);
-            }
-            if (!timer) {
-                timer = setInterval(historycheck, 100);
-            }
-        },
-        getCurrent: function() {
-            if (currentHash) {
-              return currentHash.replace(hashTrim, '');
-            } else { 
-              return ""; 
-            }
-        }
-    };
-
-    $.fn.history = function(fn) {
-        $(this).bind('history', fn);
-    };
-
-    $.fn.historyadd = function(fn) {
-        $(this).bind('historyadd', fn);
-    };
-
-    $(function() {
-        currentHash = location.hash;
-        if ($.browser.msie) {
-            msie.iframe = $('<iframe style="display:none"src="javascript:false;"></iframe>')
-                            .prependTo('body')[0];
-            msie.setHash(currentHash);
-            currentHash = msie.getHash();
-        }
-    });
-})(jQuery);
+(function($,e,b){var c="hashchange",h=document,f,g=$.event.special,i=h.documentMode,d="on"+c in e&&(i===b||i>7);function a(j){j=j||location.href;return"#"+j.replace(/^[^#]*#?(.*)$/,"$1")}$.fn[c]=function(j){return j?this.bind(c,j):this.trigger(c)};$.fn[c].delay=50;g[c]=$.extend(g[c],{setup:function(){if(d){return false}$(f.start)},teardown:function(){if(d){return false}$(f.stop)}});f=(function(){var j={},p,m=a(),k=function(q){return q},l=k,o=k;j.start=function(){p||n()};j.stop=function(){p&&clearTimeout(p);p=b};function n(){var r=a(),q=o(m);if(r!==m){l(m=r,q);$(e).trigger(c)}else{if(q!==m){location.href=location.href.replace(/#.*/,"")+q}}p=setTimeout(n,$.fn[c].delay)}$.browser.msie&&!d&&(function(){var q,r;j.start=function(){if(!q){r=$.fn[c].src;r=r&&r+a();q=$('<iframe tabindex="-1" title="empty"/>').hide().one("load",function(){r||l(a());n()}).attr("src",r||"javascript:0").insertAfter("body")[0].contentWindow;h.onpropertychange=function(){try{if(event.propertyName==="title"){q.document.title=h.title}}catch(s){}}}};j.stop=k;o=function(){return a(q.location.href)};l=function(v,s){var u=q.document,t=$.fn[c].domain;if(v!==s){u.title=h.title;u.open();t&&u.write('<script>document.domain="'+t+'"<\/script>');u.close();q.location.hash=v}}})();return j})()})(jQuery,this);
 
 
 
@@ -187,7 +117,14 @@
     if (e.keyCode == 13) {
         $('#search_filtered_div').addClass('no-display');
         if (!$('#search_filtered_div').hasClass('no-display') || (gSelectedIndex < 0)) {
-            return true;
+            if ($("#searchResults").is(":hidden")) {
+              // if results aren't showing, return true to allow search to execute
+              return true;
+            } else {
+              // otherwise, results are already showing, so allow ajax to auto refresh the results
+              // and ignore this Enter press to avoid the reload.
+              return false;
+            }
         } else if (kd && gSelectedIndex >= 0) {
             window.location = toroot + gMatches[gSelectedIndex].link;
             return false;
@@ -335,9 +272,8 @@
 function submit_search() {
   var query = document.getElementById('search_autocomplete').value;
   location.hash = 'q=' + query;
-  $.history.add('q=' + query);
   loadSearchResults();
-  $("#searchResults").slideDown();
+  $("#searchResults").slideDown('slow');
   return false;
 }
 
@@ -346,9 +282,11 @@
   $("#searchResults").slideUp();
   $(".search .close").addClass("hide");
   location.hash = '';
-  drawOptions.setInput(document.getElementById("searchResults"));
   
-  $("#search_autocomplete").blur();
+  $("#search_autocomplete").val("").blur();
+  
+  // reset the ajax search callback to nothing, so results don't appear unless ENTER
+  searchControl.setSearchStartingCallback(this, function(control, searcher, query) {});
   return false;
 }
 
@@ -367,19 +305,9 @@
 
             
       google.load('search', '1');
+      var searchControl;
 
       function loadSearchResults() {
-        if (location.hash.indexOf("q=") == -1) {
-          // if there's no query in the url, don't search and make sure results are hidden
-          $('#searchResults').hide();
-          return;
-        }
-        
-        var $results = $("#searchResults");
-        if ($results.is(":hidden")) {
-          $results.slideDown();
-        }
-        
         document.getElementById("search_autocomplete").style.color = "#000";
 
         // create search control
@@ -430,7 +358,7 @@
         // configure result options
         searchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);
         searchControl.setLinkTarget(google.search.Search.LINK_TARGET_SELF);
-        searchControl.setTimeoutInterval(google.search.SearchControl.TIMEOUT_LONG);
+        searchControl.setTimeoutInterval(google.search.SearchControl.TIMEOUT_SHORT);
         searchControl.setNoResultsString(google.search.SearchControl.NO_RESULTS_DEFAULT_STRING);
 
         // upon ajax search, refresh the url and search title
@@ -438,7 +366,6 @@
           updateResultTitle(query);
           var query = document.getElementById('search_autocomplete').value;
           location.hash = 'q=' + query;
-          $.history.add('q=' + query);
         });
 
         // draw the search results box
@@ -453,16 +380,36 @@
       // End of loadSearchResults
 
 
-      google.setOnLoadCallback(loadSearchResults, true);
-
-      // when an event on the browser history occurs (back, forward, load) perform a search
-      $(window).history(function(e, hash) {
-        var query = decodeURI(getQuery(hash));
-        if (query == "undefined") {
-          hideResults(); 
-          return; 
+      google.setOnLoadCallback(function(){
+        if (location.hash.indexOf("q=") == -1) {
+          // if there's no query in the url, don't search and make sure results are hidden
+          $('#searchResults').hide();
+          return;
+        } else {
+          // first time loading search results for this page
+          $('#searchResults').slideDown('slow');
+          $(".search .close").removeClass("hide");
+          loadSearchResults();
         }
+      }, true);
+
+      // when an event on the browser history occurs (back, forward, load) requery hash and do search
+      $(window).hashchange( function(){
+        // Exit if the hash isn't a search query or there's an error in the query
+        if ((location.hash.indexOf("q=") == -1) || (query == "undefined")) {
+          // If the results pane is open, close it.
+          if (!$("#searchResults").is(":hidden")) {
+            hideResults();
+          }
+          return;
+        }
+
+        // Otherwise, we have a search to do
+        var query = decodeURI(getQuery(location.hash));
         searchControl.execute(query);
+        $('#searchResults').slideDown('slow');
+        $("#search_autocomplete").focus();
+        $(".search .close").removeClass("hide");
 
         updateResultTitle(query);
       });
@@ -473,7 +420,7 @@
 
       // forcefully regain key-up event control (previously jacked by search api)
       $("#search_autocomplete").keyup(function(event) {
-        return search_changed(event, false, '/');
+        return search_changed(event, false, toRoot);
       });
 
       // add event listeners to each tab so we can track the browser history
diff --git a/tools/droiddoc/templates-sdk/components/masthead.cs b/tools/droiddoc/templates-sdk/components/masthead.cs
index 2003e15..51759bc 100644
--- a/tools/droiddoc/templates-sdk/components/masthead.cs
+++ b/tools/droiddoc/templates-sdk/components/masthead.cs
@@ -28,16 +28,22 @@
   <div class="morehover" id="moremenu">
     <div class="top"></div>
     <div class="mid">
+      <div class="header">Links</div>
+      <ul>
+        <li><a href="https://play.google.com/apps/publish/">Google Play Developer Console</a></li>
+        <li><a href="http://android-developers.blogspot.com/">Android Developers Blog</a></li>
+        <li><a href="<?cs var:toroot ?>about/index.html">About Android</a></li>
+      </ul>
       <div class="header">Android Sites</div>
       <ul>
         <li><a href="http://www.android.com">Android.com</a></li>
         <li class="active"><a>Android Developers</a></li>
         <li><a href="http://source.android.com">Android Open Source Project</a></li>
       </ul>
-      <div class="header">Support</div>
+      <!-- <div class="header">Support</div>
       <ul>
         <li><a href="<?cs var:toroot ?>support.html">Developer Support</a></li>
-      </ul>
+      </ul> -->
       <div class="header">Languages</div>
         <div id="language" class="locales">
           <select name="language" onChange="changeLangPref(this.value, true)">
@@ -66,8 +72,8 @@
       <form onsubmit="return submit_search()">
         <input id="search_autocomplete" type="text" value="" autocomplete="off" name="q"
 onfocus="search_focus_changed(this, true)" onblur="search_focus_changed(this, false)"
-onkeydown="return search_changed(event, true, '/')" onkeyup="return search_changed(event, false,
-'/')" />
+onkeydown="return search_changed(event, true, '<?cs var:toroot ?>')" 
+onkeyup="return search_changed(event, false, '<?cs var:toroot ?>')" />
       </form>
       <div class="right"></div>
         <a class="close hide">close</a>
diff --git a/tools/droiddoc/templates-sdk/docpage.cs b/tools/droiddoc/templates-sdk/docpage.cs
index 181f777..3f9c01a 100644
--- a/tools/droiddoc/templates-sdk/docpage.cs
+++ b/tools/droiddoc/templates-sdk/docpage.cs
@@ -44,17 +44,19 @@
   <?cs if:(!fullpage && !header.hide) ?>
     <?cs if:page.landing ?><?cs # header logic for docs that are landing pages ?>
       <div class="landing-banner">
+        <?cs if:page.landing.image ?><?cs # use two-column layout only if there's an image ?>
         <div class="col-6">
-          <?cs if:page.landing.image ?>
           <img src="<?cs var:toroot ?><?cs var:page.landing.image ?>" alt="" />
-          <?cs /if ?>
         </div>
         <div class="col-6">
+        <?cs /if ?>
           <h1 itemprop="name" style="margin-bottom:0;"><?cs var:page.title ?></h1>
           <p itemprop="description"><?cs var:page.landing.intro ?></p>
           
-          <p><a href="<?cs var:page.landing.next ?>" class="next-page-link">LEARN MORE</a></p>
+          <p><a class="next-page-link topic-start-link"></a></p>
+        <?cs if:page.landing.image ?>
         </div>
+        <?cs /if ?>
       </div>
     <?cs else ?>
       <h1 itemprop="name"><?cs var:page.title ?></h1>
diff --git a/tools/droiddoc/templates-sdk/head_tag.cs b/tools/droiddoc/templates-sdk/head_tag.cs
index 3f91ad3..175403e 100644
--- a/tools/droiddoc/templates-sdk/head_tag.cs
+++ b/tools/droiddoc/templates-sdk/head_tag.cs
@@ -11,7 +11,7 @@
 
 <!-- BASIC STYLESHEETS -->
 <link rel="stylesheet"
-href="//fonts.googleapis.com/css?family=Roboto:regular,medium,thin,italic,mediumitalic,bold" title="roboto">
+href="<?cs if:android.whichdoc != 'online' ?>http:<?cs /if ?>//fonts.googleapis.com/css?family=Roboto:regular,medium,thin,italic,mediumitalic,bold" title="roboto">
 <link href="<?cs var:toroot ?>assets/css/default.css" rel="stylesheet" type="text/css">
 
 <?cs if:reference ?>
@@ -20,14 +20,12 @@
 type="text/css">
 <?cs /if ?>
 
-<?cs if:carousel ?>
-<!-- homepage carousel -->
-<link href="<?cs var:toroot ?>assets/css/home.css" rel="stylesheet" type="text/css">
-<?cs /if ?>
-
 <!-- BASIC JAVASCRIPT -->
 <script src="<?cs var:toroot ?>assets/js/global-libraries-combined.js"
         type="text/javascript"></script>
+<script type="text/javascript">
+  var toRoot = "<?cs var:toroot ?>";
+</script>
 <script src="<?cs var:toroot ?>assets/js/docs.js" type="text/javascript"></script>
 
 <?cs if:carousel ?>
@@ -36,7 +34,7 @@
 <?cs /if ?>
 
 <!-- search -->
-<script src="//www.google.com/jsapi" type="text/javascript"></script>
+<script src="<?cs if:android.whichdoc != 'online' ?>http:<?cs /if ?>//www.google.com/jsapi" type="text/javascript"></script>
 <script src="<?cs var:toroot ?>assets/js/search_autocomplete.js" type="text/javascript"></script>
 
 <?cs if:tabbedList ?>
@@ -48,10 +46,5 @@
 <script src="<?cs var:toroot ?>assets/js/droiddoc.js" type="text/javascript"></script>
 <?cs /if ?>
 <script src="<?cs var:toroot ?>navtree_data.js" type="text/javascript"></script>
-<script type="text/javascript">
-  setToRoot("<?cs var:toroot ?>");
-  var basePath = getBaseUri(location.pathname);
-  var SITE_ROOT = toRoot + basePath.substring(1,basePath.indexOf("/",1));
-</script>
 
 </head>
\ No newline at end of file