Change "make PRODUCT-XXX-tests" to build only tests-build-target

Change-Id: Ib1a1a7b09ea6f1c3eea84394dcd6e3ebcda81e1a
diff --git a/core/Makefile b/core/Makefile
index 7b67f88..0adc673 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -831,8 +831,6 @@
 .PHONY: userdataimage-nodeps
 userdataimage-nodeps: $(INTERNAL_USERIMAGES_DEPS)
 	$(build-userdataimage-target)
-	$(hide)mkdir -p $(DIST_DIR)
-	$(hide)cp $(INSTALLED_USERDATAIMAGE_TARGET) $(DIST_DIR)
 
 #######
 ## data partition tarball
@@ -1106,12 +1104,15 @@
 .PHONY: tests-zip-package
 tests-zip-package: $(BUILT_TESTS_ZIP_PACKAGE)
 
-# Dist the files needed by tests builds
-# So the build server can run the following commands to build tests packages while avoid a full build:
-# $make -j16 tests-zip-package userdataimage-nodeps dist showcommands TARGET_BUILD_VARIANT=tests TARGET_PRODUCT=passion
-ifeq ($(filter $(DEFAULT_GOAL) tests-zip-package,$(MAKECMDGOALS)),tests-zip-package)
-  $(call dist-for-goals, tests-zip-package, \
-     $(BUILT_TESTS_ZIP_PACKAGE))
+# Target needed by tests build
+.PHONY: tests-build-target
+tests-build-target: $(BUILT_TESTS_ZIP_PACKAGE) \
+                    $(BUILT_USERDATAIMAGE_TARGET)
+
+ifneq (,$(filter $(MAKECMDGOALS),tests-build-target))
+  $(call dist-for-goals, tests-build-target, \
+          $(BUILT_TESTS_ZIP_PACKAGE) \
+          $(BUILT_USERDATAIMAGE_TARGET))
 endif
 
 # -----------------------------------------------------------------