build: interpose zephyr_flash_debug.py in debug/debugserver targets

Just as was previously done for flashing, invoke zephyr_flash_debug.py
from the build system debug and debugserver targets by default. The
Python script will fall back on the corresponding shell script if it
doesn't have its own implementation.

The shell script can be used instead, just as with flashing, by
setting USE_ZEPHYR_FLASH_DEBUG_SHELL to any nonempty value.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
diff --git a/Makefile b/Makefile
index 89c2022..bc675e4 100644
--- a/Makefile
+++ b/Makefile
@@ -1390,9 +1390,13 @@
 endif
 
 ifneq ($(DEBUG_SCRIPT),)
+ifeq ($(USE_ZEPHYR_FLASH_DEBUG_SHELL),)
+debug: zephyr
+	$(Q)$(srctree)/scripts/support/zephyr_flash_debug.py debug $(srctree)/scripts/support/$(DEBUG_SCRIPT)
+else
 debug: zephyr
 	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/support/$(DEBUG_SCRIPT) debug
-
+endif
 else
 debug: FORCE
 	@echo Debugging not supported with this board.
diff --git a/Makefile.inc b/Makefile.inc
index d4ec795..a2895df 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -100,8 +100,13 @@
 endif
 
 ifneq ($(DEBUG_SCRIPT),)
+ifeq ($(USE_ZEPHYR_FLASH_DEBUG_SHELL),)
+debugserver: FORCE
+	$(Q)$(ZEPHYR_BASE)/scripts/support/zephyr_flash_debug.py debugserver $(ZEPHYR_BASE)/scripts/support/$(DEBUG_SCRIPT)
+else
 debugserver: FORCE
 	$(Q)$(CONFIG_SHELL) $(ZEPHYR_BASE)/scripts/support/$(DEBUG_SCRIPT) debugserver
+endif
 else
 debugserver: FORCE
 	@echo Debugging not supported with this board.