Merge "Rely only on NDK libs if built against the NDK."
diff --git a/core/cleanbuild.mk b/core/cleanbuild.mk
index 45f178c..c17902d 100644
--- a/core/cleanbuild.mk
+++ b/core/cleanbuild.mk
@@ -78,6 +78,10 @@
     $(info Clean step: $(INTERNAL_CLEAN_STEP.$(step))) \
     $(shell $(INTERNAL_CLEAN_STEP.$(step))) \
    )
+  # If we are running mm/mmm, we should copy over the other clean steps too.
+  ifneq ($(ONE_SHOT_MAKEFILE),)
+    INTERNAL_CLEAN_STEPS := $(strip $(CURRENT_CLEAN_STEPS) $(steps))
+  endif
   steps :=
 endif
 CURRENT_CLEAN_BUILD_VERSION :=
diff --git a/core/cleanspec.mk b/core/cleanspec.mk
index d4a8eed..a3eb7cd 100644
--- a/core/cleanspec.mk
+++ b/core/cleanspec.mk
@@ -63,7 +63,13 @@
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
 # ************************************************
 
+ifneq ($(ONE_SHOT_MAKEFILE),)
+cs_subdirs := $(dir $(ONE_SHOT_MAKEFILE))
+else
+cs_subdirs := .
+endif
 subdir_cleanspecs := \
-    $(shell build/tools/findleaves.py --prune=out --prune=.repo --prune=.git . CleanSpec.mk)
+    $(shell build/tools/findleaves.py --prune=out --prune=.repo --prune=.git $(cs_subdirs) CleanSpec.mk)
 include $(subdir_cleanspecs)
+cs_subdirs :=
 subdir_cleanspecs :=
diff --git a/envsetup.sh b/envsetup.sh
index e5c60cf..3694755 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -937,7 +937,7 @@
         shift 2
     fi
     local adbOptions=${adbTarget}
-    echo adbOptions = ${adbOptions}
+    #echo adbOptions = ${adbOptions}
 
     # runhat options
     local targetPid=$1
@@ -954,8 +954,11 @@
     fi
 
     # issue "am" command to cause the hprof dump
-    local devFile=/sdcard/hprof-$targetPid
+    local sdcard=$(adb shell echo -n '$EXTERNAL_STORAGE')
+    local devFile=$sdcard/hprof-$targetPid
+    #local devFile=/data/local/hprof-$targetPid
     echo "Poking $targetPid and waiting for data..."
+    echo "Storing data at $devFile"
     adb ${adbOptions} shell am dumpheap $targetPid $devFile
     echo "Press enter when logcat shows \"hprof: heap dump completed\""
     echo -n "> "