fix(build): add a dependency to the build directory

The build directory is never explicitly depended on. Other recipes are
pretty much guaranteed to finish before the sp_layout target requires
it. However, on extremely slow hard drives (1MB/s) that doesn't happen.
Add an explicit dependency so make waits correctly.

Change-Id: Ibafc696c27c1a1ed14d181ef330871f6539c45f7
Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com>
diff --git a/Makefile b/Makefile
index a1474a7..e7efa2e 100644
--- a/Makefile
+++ b/Makefile
@@ -509,6 +509,8 @@
 	$(and $(REMAIN),$(error Unexpected source files present: $(REMAIN)))
 endef
 
+${BUILD_PLAT}:
+	$(Q)mkdir -p "$@"
 
 # NOTE: The line continuation '\' is required in the next define otherwise we
 # end up with a line-feed characer at the end of the last c filename.
@@ -537,7 +539,7 @@
 	$(eval $(call MAKE_OBJS,$(BUILD_DIR),$(SOURCES),${IMG_PREFIX}))
 	$(eval $(call MAKE_LD,$(LINKERFILE),$(${IMG_PREFIX}_LINKERFILE),${IMG_PREFIX}))
 
-$(BUILD_DIR) :
+$(BUILD_DIR) : ${BUILD_PLAT}
 	$$(Q)mkdir -p "$$@"
 
 $(ELF) : $(OBJS) $(LINKERFILE)
@@ -620,7 +622,7 @@
   $(eval $(call MAKE_IMG,ivy))
 endif
 
-SP_LAYOUT:
+SP_LAYOUT: ${BUILD_PLAT}
 	${Q}tools/generate_json/generate_json.sh \
 		$(BUILD_PLAT) $(SECURE_PARTITIONS)