Builds boot-debug.img if INSTALLED_BOOTIMAGE_TARGET.

This causes boot-debug.img to build if its main dependency
INSTALLED_BOOTIMAGE_TARGET (boot.img) is defined.

This fixes an issue where boot-debug.img was missing when
BUILDING_BOOT_IMAGE=false, but boot.img exists because the board uses
recovery as boot.

Bug: 170644849
Test: Build target that sets PRODUCT_BUILD_BOOT_IMAGE and
      PRODUCT_BUILD_RECOVERY_IMAGE false,
      observe no boot-debug.img.
Test: Build target that sets BOARD_USES_RECOVERY_AS_BOOT,
      observe boot-debug.img.
Change-Id: Ic887ea93d4c5181eca0f82c3cdf3ce3b72f4c185
diff --git a/core/Makefile b/core/Makefile
index 48ba059..a46e156 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -2094,7 +2094,7 @@
 #
 # Note: it's intentional to skip signing for boot-debug.img, because it
 # can only be used if the device is unlocked with verification error.
-ifdef BUILDING_BOOT_IMAGE
+ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
 ifneq ($(strip $(TARGET_NO_KERNEL)),true)
 ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
   INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-debug,$(BOARD_KERNEL_BINARIES)), \
@@ -2149,7 +2149,7 @@
 	$(foreach b,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(call build-debug-bootimage-target,$b))
 
 endif # TARGET_NO_KERNEL
-endif # BUILDING_BOOT_IMAGE
+endif # INSTALLED_BOOTIMAGE_TARGET
 
 ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
 ifeq ($(BUILDING_RAMDISK_IMAGE),true)