Merge "Add a script that verifies OTA package signature."
diff --git a/core/binary.mk b/core/binary.mk
index b9cff65..058c7e4 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -216,7 +216,6 @@
     ifneq (,$(filter r10 r11,$(LOCAL_NDK_VERSION)))
       ifeq (c++_static,$(LOCAL_NDK_STL_VARIANT))
         my_ndk_stl_static_lib := $(my_libcxx_libdir)/libc++_static.a
-        my_ldlibs += -ldl
       else
         my_ndk_stl_shared_lib_fullpath := $(my_libcxx_libdir)/libc++_shared.so
       endif
@@ -225,7 +224,6 @@
         my_ndk_stl_static_lib := \
           $(my_libcxx_libdir)/libc++_static.a \
           $(my_libcxx_libdir)/libc++abi.a
-        my_ldlibs += -ldl
       else
         my_ndk_stl_shared_lib_fullpath := $(my_libcxx_libdir)/libc++_shared.so
       endif
@@ -236,6 +234,8 @@
       endif
     endif
 
+    my_ldlibs += -ldl
+
     my_ndk_stl_cppflags := -std=c++11
   else # LOCAL_NDK_STL_VARIANT is not c++_* either
   ifneq (,$(filter gnustl_%, $(LOCAL_NDK_STL_VARIANT)))
@@ -418,7 +418,7 @@
 
 ifneq ($(LOCAL_NO_LIBCOMPILER_RT),true)
 # Add in libcompiler_rt for all regular device builds
-ifeq (,$(LOCAL_SDK_VERSION)$(WITHOUT_LIBCOMPILER_RT))
+ifeq (,$(WITHOUT_LIBCOMPILER_RT))
   my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES)
 endif
 endif
diff --git a/core/cleanbuild.mk b/core/cleanbuild.mk
index de6a5eb..6a29585 100644
--- a/core/cleanbuild.mk
+++ b/core/cleanbuild.mk
@@ -151,24 +151,18 @@
 # necessary to keep things consistent.
 
 previous_build_config_file := $(PRODUCT_OUT)/previous_build_config.mk
+current_build_config_file := $(PRODUCT_OUT)/current_build_config.mk
 
 current_build_config := \
     $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)
-current_sanitize_target := $(strip $(SANITIZE_TARGET))
-ifeq (,$(current_sanitize_target))
-  current_sanitize_target := false
-endif
 force_installclean := false
-force_objclean := false
 
 # Read the current state from the file, if present.
 # Will set PREVIOUS_BUILD_CONFIG.
 #
 PREVIOUS_BUILD_CONFIG :=
-PREVIOUS_SANITIZE_TARGET :=
 -include $(previous_build_config_file)
 PREVIOUS_BUILD_CONFIG := $(strip $(PREVIOUS_BUILD_CONFIG))
-PREVIOUS_SANITIZE_TARGET := $(strip $(PREVIOUS_SANITIZE_TARGET))
 
 ifdef PREVIOUS_BUILD_CONFIG
   ifneq "$(current_build_config)" "$(PREVIOUS_BUILD_CONFIG)"
@@ -181,27 +175,19 @@
   endif
 endif  # else, this is the first build, so no need to clean.
 
-ifdef PREVIOUS_SANITIZE_TARGET
-  ifneq "$(current_sanitize_target)" "$(PREVIOUS_SANITIZE_TARGET)"
-    $(info *** SANITIZE_TARGET changed: "$(PREVIOUS_SANITIZE_TARGET)" -> "$(current_sanitize_target)")
-    force_objclean := true
-  endif
-endif  # else, this is the first build, so no need to clean.
-
 # Write the new state to the file.
 #
-ifneq ($(PREVIOUS_BUILD_CONFIG)-$(PREVIOUS_SANITIZE_TARGET),$(current_build_config)-$(current_sanitize_target))
 $(shell \
-  mkdir -p $(dir $(previous_build_config_file)) && \
+  mkdir -p $(dir $(current_build_config_file)) && \
   echo "PREVIOUS_BUILD_CONFIG := $(current_build_config)" > \
-      $(previous_build_config_file) && \
-  echo "PREVIOUS_SANITIZE_TARGET := $(current_sanitize_target)" >> \
-      $(previous_build_config_file) \
+      $(current_build_config_file) \
  )
-endif
+$(shell cmp $(current_build_config_file) $(previous_build_config_file) > /dev/null 2>&1 || \
+  mv -f $(current_build_config_file) $(previous_build_config_file))
+
 PREVIOUS_BUILD_CONFIG :=
-PREVIOUS_SANITIZE_TARGET :=
 previous_build_config_file :=
+current_build_config_file :=
 current_build_config :=
 
 #
@@ -248,12 +234,6 @@
 	$(PRODUCT_OUT)/data-qemu/* \
 	$(PRODUCT_OUT)/userdata-qemu.img
 
-# The files/dirs to delete during an objclean, which removes any files
-# in the staging and emulator data partitions.
-objclean_files := \
-	$(TARGET_OUT_INTERMEDIATES) \
-	$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES)
-
 # 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)))
@@ -273,12 +253,6 @@
 	$(hide) rm -rf $(FILES)
 	@echo "Deleted images and staging directories."
 
-.PHONY: objclean
-objclean: FILES := $(objclean_files)
-objclean:
-	$(hide) rm -rf $(FILES)
-	@echo "Deleted images and staging directories."
-
 ifeq "$(force_installclean)" "true"
   $(info *** Forcing "make installclean"...)
   $(info *** rm -rf $(dataclean_files) $(installclean_files))
@@ -287,14 +261,6 @@
 endif
 force_installclean :=
 
-ifeq "$(force_objclean)" "true"
-  $(info *** Forcing cleanup of intermediate files...)
-  $(info *** rm -rf $(objclean_files))
-  $(shell rm -rf $(objclean_files))
-  $(info *** Done with the cleaning, now starting the real build.)
-endif
-force_objclean :=
-
 ###########################################################
 
 .PHONY: clean-jack-files
diff --git a/core/envsetup.mk b/core/envsetup.mk
index 39a754b..8794c8a 100644
--- a/core/envsetup.mk
+++ b/core/envsetup.mk
@@ -469,7 +469,7 @@
 TARGET_ROOT_OUT_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)
 TARGET_ROOT_OUT_SBIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/sbin
 TARGET_ROOT_OUT_BIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/bin
-TARGET_OUT_COVERAGE := $(PRODUCT_OUT)/coverages
+TARGET_OUT_COVERAGE := $(PRODUCT_OUT)/coverage
 
 TARGET_ROOT_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ROOT)
 TARGET_ROOT_OUT_BIN := $(TARGET_ROOT_OUT)/bin