bootloader: add DEBUG make flag

make DEBUG=1 tells uefi-build.sh to build the DEBUG target, which adds
lots of diagnostic messages that can be useful for people debugging
firmware or early-boot issues (e.g. register dumps in the default
exception handler).

Test: build and flash bootloader images built with and without DEBUG=1
Change-Id: Ic34f5dcc24336a166f15e260ebc88796f8701291
Signed-off-by: Greg Hackmann <ghackmann@google.com>
diff --git a/bootloader/Makefile b/bootloader/Makefile
index 3ecc46e..2a57f0f 100644
--- a/bootloader/Makefile
+++ b/bootloader/Makefile
@@ -5,6 +5,12 @@
 PRODUCT_OUT?=out/target/product/hikey
 DIST_DIR?=$(ANDROID_BUILD_TOP)/out/dist
 
+ifdef DEBUG
+	TARGET = DEBUG
+else
+	TARGET = RELEASE
+endif
+
 all: $(DIST_DIR)/fip.bin $(DIST_DIR)/l-loader.bin
 
 $(DIST_DIR)/fip.bin:
@@ -19,12 +25,12 @@
 	mkdir -p $(DIST_DIR) && \
 	mkdir -p $(ANDROID_BUILD_TOP)/$(PRODUCT_OUT)/obj/uefi && \
 	ln -sf $(ANDROID_BUILD_TOP)/$(PRODUCT_OUT)/obj/uefi $(EDK2_DIR)/Build/HiKey && \
-	$(UEFI_TOOLS_DIR)/uefi-build.sh -b RELEASE -D EDK2_OUT_DIR=$(ANDROID_BUILD_TOP)/$(PRODUCT_OUT)/obj/uefi -a $(ATF_DIR) hikey && \
-	cp $(EDK2_DIR)/Build/HiKey/RELEASE_GCC49/FV/fip.bin $(DIST_DIR)/
+	$(UEFI_TOOLS_DIR)/uefi-build.sh -b $(TARGET) -D EDK2_OUT_DIR=$(ANDROID_BUILD_TOP)/$(PRODUCT_OUT)/obj/uefi -a $(ATF_DIR) hikey && \
+	cp $(EDK2_DIR)/Build/HiKey/$(TARGET)_GCC49/FV/fip.bin $(DIST_DIR)/
 
 $(DIST_DIR)/l-loader.bin: $(DIST_DIR)/fip.bin
 	cd $(ANDROID_BUILD_TOP)/device/linaro/hikey/l-loader && \
-	ln -sf $(EDK2_DIR)/Build/HiKey/RELEASE_GCC49/FV//bl1.bin && \
+	ln -sf $(EDK2_DIR)/Build/HiKey/$(TARGET)_GCC49/FV//bl1.bin && \
 	make CROSS_COMPILE=arm-linux-androideabi- l-loader.bin && \
 	mv l-loader.bin $(DIST_DIR)/