auto import from //branches/cupcake/...@132569
diff --git a/core/Makefile b/core/Makefile
index bb18c4b..2983628 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -198,20 +198,6 @@
 apkcerts-list: $(APKCERTS_FILE)
 
 # -----------------------------------------------------------------
-# installed file list
-INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
-$(INSTALLED_FILES_FILE): $(ALL_DEFAULT_INSTALLED_MODULES)
-	@echo Installed file list: $@
-	@mkdir -p $(dir $@)
-	@rm -f $@
-	$(hide) (cd $(PRODUCT_OUT) && \
-	         find system data -type f -printf 'name="%p" size=%s\n') | \
-		sort > $@
-
-.PHONY: installed-file-list
-installed-file-list: $(INSTALLED_FILES_FILE)
-
-# -----------------------------------------------------------------
 # module info file
 ifdef CREATE_MODULE_INFO_FILE
   MODULE_INFO_FILE := $(PRODUCT_OUT)/module-info.txt
@@ -901,6 +887,20 @@
 target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
 
 # -----------------------------------------------------------------
+# installed file list
+# Depending on $(INSTALLED_SYSTEMIMAGE) ensures that it
+# gets the DexOpt one if we're doing that.
+INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
+$(INSTALLED_FILES_FILE): $(INSTALLED_SYSTEMIMAGE)
+	@echo Installed file list: $@
+	@mkdir -p $(dir $@)
+	@rm -f $@
+	$(hide) build/tools/fileslist.py $(TARGET_OUT) $(TARGET_OUT_DATA) > $@
+
+.PHONY: installed-file-list
+installed-file-list: $(INSTALLED_FILES_FILE)
+
+# -----------------------------------------------------------------
 # A zip of the tests that are built when running "make tests".
 # This is very similar to BUILT_TARGET_FILES_PACKAGE, but we
 # only grab SYSTEM and DATA, and it's called "*-tests-*.zip".
diff --git a/core/cleanbuild.mk b/core/cleanbuild.mk
index 0b292bf..01bf9a5 100644
--- a/core/cleanbuild.mk
+++ b/core/cleanbuild.mk
@@ -104,8 +104,14 @@
   # Don't bother with this extra part when explicitly building the sdk product.
   building_sdk :=
 endif
-current_build_config := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)$(building_sdk)
+
+# A change in the list of locales warrants an installclean, too.
+locale_list := $(subst $(space),$(comma),$(strip $(PRODUCT_LOCALES)))
+
+current_build_config := \
+    $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)$(building_sdk)-{$(locale_list)}
 building_sdk :=
+locale_list :=
 force_installclean := false
 
 # Read the current state from the file, if present.
diff --git a/core/combo/darwin-x86.mk b/core/combo/darwin-x86.mk
index cc6a895..2150960 100644
--- a/core/combo/darwin-x86.mk
+++ b/core/combo/darwin-x86.mk
@@ -93,9 +93,5 @@
 stat -f "%z" $(1)
 endef
 
-# Which gcc to use to build qemu, which doesn't work right when
-# built with 4.2.1 or later.
-GCCQEMU := prebuilt/darwin-x86/toolchain/i686-apple-darwin8-4.0.1/bin/gcc
-
 endif
 
diff --git a/core/combo/linux-x86.mk b/core/combo/linux-x86.mk
index 2c729ad..372c63e 100644
--- a/core/combo/linux-x86.mk
+++ b/core/combo/linux-x86.mk
@@ -12,12 +12,7 @@
 define get-file-size
 stat --format "%s" "$(1)"
 endef
-
-# Which gcc to use to build qemu, which doesn't work right when
-# built with 4.2.1 or later.
-GCCQEMU := prebuilt/linux-x86/toolchain/i686-linux-gnu-3.4.6/bin/gcc
-endif # _HOST
-
+endif
 
 # On the sim, we build the "host" tools in 64 bit iff the compiler
 # does it for us automatically.  In other words, that means on 64 bit
diff --git a/core/main.mk b/core/main.mk
index 1ea13ac..1369944 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -575,7 +575,8 @@
 	$(INSTALLED_BOOTIMAGE_TARGET) \
 	$(INSTALLED_RECOVERYIMAGE_TARGET) \
 	$(INSTALLED_USERDATAIMAGE_TARGET) \
-	$(INTERNAL_DEFAULT_DOCS_TARGETS)
+	$(INTERNAL_DEFAULT_DOCS_TARGETS) \
+	$(INSTALLED_FILES_FILE)
 
 # The actual files built by the droidcore target changes depending
 # on the build variant.
diff --git a/core/product_config.mk b/core/product_config.mk
index a9021cc..93671f4 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -149,6 +149,15 @@
 PRODUCT_LOCALES := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_LOCALES))
 # TODO: also keep track of things like "port", "land" in product files.
 
+# If CUSTOM_LOCALES contains any locales not already included
+# in PRODUCT_LOCALES, add them to PRODUCT_LOCALES.
+extra_locales := $(filter-out $(PRODUCT_LOCALES),$(CUSTOM_LOCALES))
+ifneq (,$(extra_locales))
+  $(info Adding CUSTOM_LOCALES [$(extra_locales)] to PRODUCT_LOCALES [$(PRODUCT_LOCALES)])
+  PRODUCT_LOCALES += $(extra_locales)
+  extra_locales :=
+endif
+
 # Assemble the list of options.
 PRODUCT_AAPT_CONFIG := $(PRODUCT_LOCALES)