Merge from open-source gingerbread

Change-Id: I7dce3075bab5831b48a66ef43a32a2be82eda19a
diff --git a/CleanSpec.mk b/CleanSpec.mk
index f0beb1d..e70a50a 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -53,6 +53,7 @@
 $(call add-clean-step, find $(PRODUCT_OUT) -name "*.apk" | xargs rm)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(OUT_DIR))
 
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
 # ************************************************
diff --git a/core/Makefile b/core/Makefile
index a74f855..72d4ae7 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -864,7 +864,9 @@
 	  $(HOST_OUT_EXECUTABLES)/bsdiff \
 	  $(HOST_OUT_EXECUTABLES)/imgdiff \
 	  $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
-	  $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar
+	  $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
+	  $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \
+	  $(HOST_OUT_EXECUTABLES)/make_ext4fs
 
 .PHONY: otatools
 otatools: $(OTATOOLS)
diff --git a/core/base_rules.mk b/core/base_rules.mk
index 5bb6b77..3c11673 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -57,8 +57,12 @@
 
 LOCAL_MODULE_TAGS := $(sort $(LOCAL_MODULE_TAGS))
 ifeq (,$(LOCAL_MODULE_TAGS))
-# Modules without tags fall back to user (which is changed to user eng below)
+ifeq (true,$(LOCAL_UNINSTALLABLE_MODULE))
+LOCAL_MODULE_TAGS := optional
+else
+# Installable modules without tags fall back to user (which is changed to user eng below)
 LOCAL_MODULE_TAGS := user
+endif
 #$(warning default tags: $(lastword $(filter-out config/% out/%,$(MAKEFILE_LIST))))
 endif
 
diff --git a/core/cleanbuild.mk b/core/cleanbuild.mk
index cf25ce1..821b03a 100644
--- a/core/cleanbuild.mk
+++ b/core/cleanbuild.mk
@@ -160,8 +160,6 @@
 
 # The files/dirs to delete during an installclean.  This includes the
 # non-common APPS directory, which may contain the wrong resources.
-# Use "./" in front of the paths to avoid accidentally deleting random
-# parts of the filesystem if any of the *_OUT vars resolve to blank.
 #
 # Deletes all of the files that change between different build types,
 # like "make user" vs. "make sdk".  This lets you work with different
@@ -174,28 +172,34 @@
 #     $ make -j8 sdk
 #
 installclean_files := \
-	./$(HOST_OUT)/obj/NOTICE_FILES \
-	./$(HOST_OUT)/sdk \
-	./$(PRODUCT_OUT)/*.img \
-	./$(PRODUCT_OUT)/*.txt \
-	./$(PRODUCT_OUT)/*.xlb \
-	./$(PRODUCT_OUT)/*.zip \
-	./$(PRODUCT_OUT)/data \
-	./$(PRODUCT_OUT)/obj/APPS \
-	./$(PRODUCT_OUT)/obj/NOTICE_FILES \
-	./$(PRODUCT_OUT)/obj/PACKAGING \
-	./$(PRODUCT_OUT)/recovery \
-	./$(PRODUCT_OUT)/root \
-	./$(PRODUCT_OUT)/system \
-	./$(PRODUCT_OUT)/dex_bootjars \
-	./$(PRODUCT_OUT)/obj/JAVA_LIBRARIES
+	$(HOST_OUT)/obj/NOTICE_FILES \
+	$(HOST_OUT)/sdk \
+	$(PRODUCT_OUT)/*.img \
+	$(PRODUCT_OUT)/*.txt \
+	$(PRODUCT_OUT)/*.xlb \
+	$(PRODUCT_OUT)/*.zip \
+	$(PRODUCT_OUT)/data \
+	$(PRODUCT_OUT)/obj/APPS \
+	$(PRODUCT_OUT)/obj/NOTICE_FILES \
+	$(PRODUCT_OUT)/obj/PACKAGING \
+	$(PRODUCT_OUT)/recovery \
+	$(PRODUCT_OUT)/root \
+	$(PRODUCT_OUT)/system \
+	$(PRODUCT_OUT)/dex_bootjars \
+	$(PRODUCT_OUT)/obj/JAVA_LIBRARIES
 
 # The files/dirs to delete during a dataclean, which removes any files
 # in the staging and emulator data partitions.
 dataclean_files := \
-	./$(PRODUCT_OUT)/data/* \
-	./$(PRODUCT_OUT)/data-qemu/* \
-	./$(PRODUCT_OUT)/userdata-qemu.img
+	$(PRODUCT_OUT)/data/* \
+	$(PRODUCT_OUT)/data-qemu/* \
+	$(PRODUCT_OUT)/userdata-qemu.img
+
+# make sure *_OUT is set so that we won't result in deleting random parts
+# of the filesystem.
+ifneq (2,$(words $(HOST_OUT) $(PRODUCT_OUT)))
+  $(error both HOST_OUT and PRODUCT_OUT should be set at this point.)
+endif
 
 # Define the rules for commandline invocation.
 .PHONY: dataclean
@@ -212,6 +216,7 @@
 
 ifeq "$(force_installclean)" "true"
   $(info *** Forcing "make installclean"...)
+  $(info *** rm -rf $(dataclean_files) $(installclean_files))
   $(shell rm -rf $(dataclean_files) $(installclean_files))
   $(info *** Done with the cleaning, now starting the real build.)
 endif
diff --git a/core/combo/HOST_linux-x86.mk b/core/combo/HOST_linux-x86.mk
index fa2dfe3..c871613 100644
--- a/core/combo/HOST_linux-x86.mk
+++ b/core/combo/HOST_linux-x86.mk
@@ -22,6 +22,26 @@
 stat --format "%s" "$(1)" | tr -d '\n'
 endef
 
+# Special case for the Linux SDK: We need to use a special cross-toolchain
+# that generates machine code that will run properly on Ubuntu 8.04 (Hardy)
+# By default, the code generated by the Lucid host toolchain will not run
+# on previous versions of the platform, due to GLibc ABI mistmatches
+# (Lucid is 2.11, Hardy is 2.7)
+#
+# Note that components that need to be built as 64-bit (e.g. clearsilver
+# which is loaded by the 64-bit JVM through JNI), will have to use
+# LOCAL_CC and LOCAL_CXX to override this.
+#
+ifeq ($(TARGET_PRODUCT),sdk)
+HOST_SDK_TOOLCHAIN_PREFIX := prebuilt/linux-x86/toolchain/i686-linux-glibc2.7-4.4.3/bin/i686-linux
+# Don't do anything if the toolchain is not there
+ifneq (,$(strip $(wildcard $(HOST_SDK_TOOLCHAIN_PREFIX)-gcc)))
+HOST_CC  := $(HOST_SDK_TOOLCHAIN_PREFIX)-gcc
+HOST_CXX := $(HOST_SDK_TOOLCHAIN_PREFIX)-g++
+HOST_AR  := $(HOST_SDK_TOOLCHAIN_PREFIX)-ar
+endif # $(HOST_SDK_TOOLCHAIN_PREFIX)-gcc exists
+endif # TARGET_PRODUCT == sdk
+
 # We build everything in 32-bit, because some host tools are
 # 32-bit-only anyway (emulator, acc), and because it gives us
 # more consistency between the host tools and the target.
diff --git a/core/definitions.mk b/core/definitions.mk
index 6232668..11cea3f 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -1001,7 +1001,7 @@
 # it to be overriden en-masse see combo/linux-arm.make for an example.
 ifneq ($(HOST_CUSTOM_LD_COMMAND),true)
 define transform-host-o-to-shared-lib-inner
-$(HOST_CXX) \
+$(PRIVATE_CXX) \
 	-Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
 	-Wl,-rpath,\$$ORIGIN/../lib \
 	-shared -Wl,-soname,$(notdir $@) \
@@ -1051,7 +1051,7 @@
 # it to be overriden en-masse see combo/linux-arm.make for an example.
 ifneq ($(TARGET_CUSTOM_LD_COMMAND),true)
 define transform-o-to-shared-lib-inner
-$(TARGET_CXX) \
+$(PRIVATE_CXX) \
 	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
 	-Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
 	-Wl,-rpath,\$$ORIGIN/../lib \
@@ -1113,7 +1113,7 @@
 
 ifneq ($(TARGET_CUSTOM_LD_COMMAND),true)
 define transform-o-to-executable-inner
-$(TARGET_CXX) \
+$(PRIVATE_CXX) \
 	$(TARGET_GLOBAL_LDFLAGS) \
 	-Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
 	$(TARGET_GLOBAL_LD_DIRS) \
@@ -1164,7 +1164,7 @@
 
 ifneq ($(HOST_CUSTOM_LD_COMMAND),true)
 define transform-host-o-to-executable-inner
-$(HOST_CXX) \
+$(PRIVATE_CXX) \
 	-Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
 	-Wl,-rpath,\$$ORIGIN/../lib \
 	$(HOST_GLOBAL_LD_DIRS) \
diff --git a/core/version_defaults.mk b/core/version_defaults.mk
index 8217f41..3238a45 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 := 2.3.1
+  PLATFORM_VERSION := 2.4
 endif
 
 ifeq "" "$(PLATFORM_SDK_VERSION)"
@@ -53,7 +53,7 @@
   # intermediate builds).  During development, this number remains at the
   # SDK version the branch is based on and PLATFORM_VERSION_CODENAME holds
   # the code-name of the new development work.
-  PLATFORM_SDK_VERSION := 9
+  PLATFORM_SDK_VERSION := 10
 endif
 
 ifeq "" "$(PLATFORM_VERSION_CODENAME)"
diff --git a/tools/droiddoc/templates-sdk/sdkpage.cs b/tools/droiddoc/templates-sdk/sdkpage.cs
index 77bb959..6c35b81 100644
--- a/tools/droiddoc/templates-sdk/sdkpage.cs
+++ b/tools/droiddoc/templates-sdk/sdkpage.cs
@@ -29,7 +29,16 @@
       if:sdk.redirect.path ?><?cs var:sdk.redirect.path ?><?cs
       else ?>Download the SDK<?cs /if ?>
     </a> ...</p>
+
 <?cs else ?>
+<?cs # else, if NOT redirect ...
+#
+#
+# The following is for SDK/NDK pages
+#
+#
+?>
+
 <div class="g-unit" id="doc-content" >
   <div id="jd-header" class="guide-header" >
     <span class="crumb">&nbsp;</span>
@@ -37,13 +46,6 @@
   </div>
 
   <div id="jd-content">
-    <?cs
-    if:ndk ?><?cs
-    else ?><?cs
-      if:android.whichdoc == "online" ?><p><em><?cs
-      var:sdk.date ?></em></p><?cs
-      /if ?><?cs
-    /if ?>
 
 <?cs if:sdk.not_latest_version ?>
   <div class="special">
@@ -52,12 +54,23 @@
   </div>
 <?cs /if ?>
 
-<?cs if:android.whichdoc != "online" && !android.preview ?>
 
-<!-- <p>The sections below provide an overview of how to install the SDK package. </p> -->
-
-<?cs else ?>
-  <?cs if:ndk ?>
+<?cs if:ndk ?>
+<?cs #
+#
+#
+#
+#
+#
+#
+# the following is for the NDK
+#
+# (nested in if/else redirect)
+#
+#
+#
+#
+?>
 
 <p>The Android NDK is a companion tool to the Android SDK that lets you build
 performance-critical portions of your apps in native code. It provides headers and
@@ -113,54 +126,23 @@
   </tr>
   </table>
 
-  <?cs else ?><?cs if:android.whichdoc == "online" ?>
-
-  <?cs if:sdk.preview ?>
-  <p>Welcome developers! The next release of the Android platform will be
-  Android 1.6 and we are pleased to announce the availability of an early look
-  SDK to give you a head-start on developing applications for it. </p>
-
-  <p>The Android <?cs var:sdk.preview.version ?> platform includes a variety of
-  improvements and new features for users and developers. Additionally, the SDK
-  itself introduces several new capabilities that enable you to develop
-  applications more efficiently. See the <a href="features.html">Android <?cs
-  var:sdk.preview.version ?> Platform Highlights</a> document for a list of
-  highlights.</p>
-<?cs /if ?>
-<?cs # end if NDK ... the following is for the SDK ?>
-
-<?cs #
-    <div class="toggle-content special">
-    <p>The Android SDK has changed! If you've worked with the Android SDK before,
-    you will notice several important differences:</p>
-
-    <div class="toggle-content-toggleme" style="display:none">
-    <ul style="padding-bottom:.0;">
-    <li style="margin-top:.5em">The SDK downloadable package includes <em>only</em>
-    the latest version of the Android SDK Tools.</li>
-    <li>Once you've installed the SDK, you now use the Android SDK and AVD Manager
-    to download all of the SDK components that you need, such as Android platforms,
-    SDK add-ons, tools, and documentation. </li>
-    <li>The new approach is modular &mdash; you can install only the components you
-    need and update any or all components without affecting other parts of your
-    development environment.</li>
-    <li>In short, once you've installed the new SDK, you will not need to download
-    an SDK package again. Instead, you will use the Android SDK and AVD Manager to
-    keep your development environment up-to-date. </li>
-    </ul>
-    <p style="margin-top:0">If you are currently using the Android 1.6 SDK, you
-    do not need to install the new SDK, because your existing SDK already
-    includes the Android SDK and AVD Manager tool. To develop against Android
-    2.0.1, for example, you can just download the Android 2.0.1 platform (and
-    updated SDK Tools) into your existing SDK. Refer to <a
-    href="adding-components.html">Adding SDK Components</a>.</p>
-    </div>
-
-    <a href='#' class='toggle-content-button show' onclick="toggleContent(this,true);return false;">
-      <span>show more</span><span style='display:none'>show less</span>
-    </a>
-  </div>
+  <?cs else ?>
+<?cs # end if NDK ... 
+#
+#
+#
+#
+#
+#
+# the following is for the SDK
+#
+# (nested in if/else redirect and if/else NDK)
+#
+#
+#
+#
 ?>
+  <?cs if:android.whichdoc == "online" ?>
 
   <p>Welcome Developers! If you are new to the Android SDK, please read the steps below, for an
 overview of how to set up the SDK. </p>
@@ -168,7 +150,7 @@
   <p>If you're already using the Android SDK, you should
 update to the latest tools or platform using the <em>Android SDK and AVD Manager</em>, rather than
 downloading a new SDK starter package. See <a
-href="{@docRoot}sdk/adding-components.html">Adding SDK Components</a>.</p>
+href="<?cs var:toroot ?>sdk/adding-components.html">Adding SDK Components</a>.</p>
 
   <table class="download">
     <tr>
@@ -213,16 +195,6 @@
     <td><?cs var:sdk.linux_bytes ?> bytes</td>
     <td><?cs var:sdk.linux_checksum ?></td>
   </tr>
-  <?cs if:adt.zip_download ?>
-  <tr class="alt-color">
-    <td>ADT Plugin for Eclipse <?cs var:adt.zip_version ?></td>
-    <td>
-  <a href="http://dl.google.com/android/<?cs var:adt.zip_download ?>"><?cs var:adt.zip_download ?></a>
-    </td>
-    <td><?cs var:adt.zip_bytes ?> bytes</td>
-    <td><?cs var:adt.zip_checksum ?></td>
-  </tr>
-  <?cs /if ?>
   </table>
 
 
@@ -237,36 +209,21 @@
   $("#next-steps").show();
 }
 </script>
+  <?cs /if ?> <?cs # end if online ?>
 
-  <?cs /if ?>
- <?cs /if ?>
-<?cs /if ?>
+<?cs /if ?> <?cs # end if/else NDK ?>
 
-<?cs if:android.whichdoc != "online" && sdk.preview ?>
-  <p>Welcome developers! The next release of the Android platform will be
-Android <?cs var:sdk.preview.version ?> and we are pleased to announce the
-availability of an early look SDK to give you a head-start on developing
-applications for it. </p>
+<?cs /if ?> <?cs # end if/else redirect ?>
 
-  <p>The Android <?cs var:sdk.preview.version ?> platform includes a variety of
-improvements and new features for users and developers. Additionally, the SDK
-itself introduces several new capabilities that enable you to develop
-applications more efficiently. See the <a
-href="http://developer.android.com/sdk/preview/features.html">Android
-<?cs var:sdk.preview.version ?> Highlights</a> document for a list of
-highlights.</p>
-<?cs /if ?>
+<?cs call:tag_list(root.descr) ?>
 
-      <?cs call:tag_list(root.descr) ?>
-
-<?cs /if ?>
 </div><!-- end jd-content -->
 
 <?cs if:!sdk.redirect ?>
-     <?cs include:"footer.cs" ?>
+<?cs include:"footer.cs" ?>
 <?cs /if ?>
 
-</div><!-- end doc-content -->
+</div><!-- end g-unit -->
 
 <?cs include:"trailer.cs" ?>