Merge "Add mac_permissions.xml dependency."
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 74ad978..6d81733 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -125,6 +125,8 @@
 # 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 50548aa..8445c58 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -1298,7 +1298,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 +1314,7 @@
 	@echo "Package: $@"
 	$(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
 
+endif
 # -----------------------------------------------------------------
 # Old PDK stuffs, retired
 # The pdk package (Platform Development Kit)
@@ -1488,6 +1489,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/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 9ecd649..0000000
--- a/core/combo/TARGET_linux-sh.mk
+++ /dev/null
@@ -1,185 +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) \
-	-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) \
-	$(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,--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)) \
-	-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 28c031d..9c0f7b9 100644
--- a/core/combo/TARGET_linux-x86.mk
+++ b/core/combo/TARGET_linux-x86.mk
@@ -186,12 +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 $@ \
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/config.mk b/core/config.mk
index b0b5082..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 :=
 
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/dumpvar.mk b/core/dumpvar.mk
index 4a44f77..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-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
+    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/main.mk b/core/main.mk
index 08efbda..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))
 
@@ -166,11 +166,35 @@
   $(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
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/envsetup.sh b/envsetup.sh
index 84ec3e5..2da629d 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -122,6 +122,8 @@
             ;;
         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()
 {
@@ -739,6 +744,7 @@
    case "$ARCH" in
        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 cee09ce..233b136 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.
 #
diff --git a/target/board/generic_mips/BoardConfig.mk b/target/board/generic_mips/BoardConfig.mk
index 8b81c27..8c2371f 100644
--- a/target/board/generic_mips/BoardConfig.mk
+++ b/target/board/generic_mips/BoardConfig.mk
@@ -51,7 +51,3 @@
 # 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
-
-# Default to JSC until we get v8 landed
-HTTP := android
-JS_ENGINE := jsc
diff --git a/target/board/generic_mips/device.mk b/target/board/generic_mips/device.mk
index 6edcba6..8c770b5 100644
--- a/target/board/generic_mips/device.mk
+++ b/target/board/generic_mips/device.mk
@@ -19,13 +19,17 @@
 
 PRODUCT_PROPERTY_OVERRIDES := \
     ro.ril.hsxpa=1 \
-    ro.ril.gprsclass=10
+    ro.ril.gprsclass=10 \
+    ro.adb.qemud=1
 
 PRODUCT_COPY_FILES := \
-    development/data/etc/apns-conf.xml:system/etc/apns-conf.xml \
-    development/data/etc/vold.conf:system/etc/vold.conf \
-    development/tools/emulator/system/camera/media_profiles.xml:system/etc/media_profiles.xml
+    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/product/core.mk b/target/product/core.mk
index 8cf3b3e..c7ae51c 100644
--- a/target/product/core.mk
+++ b/target/product/core.mk
@@ -122,6 +122,9 @@
     uiautomator \
     telephony-common \
     mms-common \
+    zoneinfo.dat \
+    zoneinfo.idx \
+    zoneinfo.version
 
 PRODUCT_COPY_FILES += \
     system/core/rootdir/init.usb.rc:root/init.usb.rc \
@@ -140,5 +143,8 @@
         libjavacore \
         libssl \
         libz-host \
-        dalvik
+        dalvik \
+        zoneinfo-host.dat \
+        zoneinfo-host.idx \
+        zoneinfo-host.version
 endif
diff --git a/target/product/full_mips.mk b/target/product/full_mips.mk
index 886cf31..2debfec 100644
--- a/target/product/full_mips.mk
+++ b/target/product/full_mips.mk
@@ -19,9 +19,6 @@
 # mips build quite specifically for the emulator, and might not be
 # entirely appropriate to inherit from for on-device configurations.
 
-PRODUCT_PACKAGES := \
-    Camera
-
 $(call inherit-product, $(SRC_TARGET_DIR)/product/full_base_telephony.mk)
 $(call inherit-product, $(SRC_TARGET_DIR)/board/generic_mips/device.mk)