Makefile: list dependencies for RAW_MEM_ACCESS, X86_PORT_IO, X86_MSR

List all programmers which depend on the respective hwaccess features.
This is the base for a precise feature selecting in the build system.

flashrom-stable: Squashed fixup for Windows

Change-Id: I588f698780b5acd65084346bcef781cbfd1203ea
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/60114
Original-Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/72268
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/Makefile b/Makefile
index b73bcb9..b5f6f31 100644
--- a/Makefile
+++ b/Makefile
@@ -108,6 +108,40 @@
 	CONFIG_PONY_SPI \
 	CONFIG_RAYER_SPI \
 
+DEPENDS_ON_RAW_MEM_ACCESS := \
+	CONFIG_ATAPROMISE \
+	CONFIG_DRKAISER \
+	CONFIG_GFXNVIDIA \
+	CONFIG_INTERNAL \
+	CONFIG_IT8212 \
+	CONFIG_NICINTEL \
+	CONFIG_NICINTEL_EEPROM \
+	CONFIG_NICINTEL_SPI \
+	CONFIG_OGP_SPI \
+	CONFIG_SATAMV \
+	CONFIG_SATASII \
+
+DEPENDS_ON_X86_MSR := \
+	CONFIG_INTERNAL \
+
+DEPENDS_ON_X86_PORT_IO := \
+	CONFIG_ATAHPT \
+	CONFIG_ATAPROMISE \
+	CONFIG_ATAVIA \
+	CONFIG_DRKAISER \
+	CONFIG_GFXNVIDIA \
+	CONFIG_INTERNAL \
+	CONFIG_NIC3COM \
+	CONFIG_NICINTEL \
+	CONFIG_NICINTEL_EEPROM \
+	CONFIG_NICINTEL_SPI \
+	CONFIG_NICNATSEMI \
+	CONFIG_NICREALTEK \
+	CONFIG_OGP_SPI \
+	CONFIG_RAYER_SPI \
+	CONFIG_SATAMV \
+	CONFIG_SATASII \
+
 DEPENDS_ON_LIBPCI := \
 	CONFIG_ATAHPT \
 	CONFIG_ATAPROMISE \
@@ -242,6 +276,9 @@
 endif
 
 ifeq ($(TARGET_OS), $(filter $(TARGET_OS), MinGW Cygwin))
+$(call mark_unsupported,$(DEPENDS_ON_RAW_MEM_ACCESS))
+$(call mark_unsupported,$(DEPENDS_ON_X86_PORT_IO))
+$(call mark_unsupported,$(DEPENDS_ON_X86_MSR))
 FEATURE_CFLAGS += -D'IS_WINDOWS=1'
 else
 FEATURE_CFLAGS += -D'IS_WINDOWS=0'
@@ -258,8 +295,12 @@
 
 # For now we disable all PCI-based programmers on Windows/MinGW (no libpci).
 $(call mark_unsupported,$(DEPENDS_ON_LIBPCI))
-# And programmers that need raw access.
-$(call mark_unsupported,CONFIG_RAYER_SPI)
+
+else # No MinGW
+
+# NI USB-845x only supported on Windows at the moment
+$(call mark_unsupported,CONFIG_NI845X_SPI)
+
 endif
 
 ifeq ($(TARGET_OS), libpayload)
@@ -272,7 +313,9 @@
 # libpayload does not provide the romsize field in struct pci_dev that the atapromise code requires.
 $(call mark_unsupported,CONFIG_ATAPROMISE)
 # Bus Pirate, Serprog and PonyProg are not supported with libpayload (missing serial support).
-$(call mark_unsupported,CONFIG_BUSPIRATE_SPI CONFIG_SERPROG CONFIG_PONY_SPI)
+$(call mark_unsupported,$(DEPENDS_ON_SERIAL))
+# Dediprog, Developerbox, USB-Blaster, PICkit2, CH341A and FT2232 are not supported with libpayload (missing libusb support).
+$(call mark_unsupported,$(DEPENDS_ON_LIBUSB1) $(DEPENDS_ON_LIBFTDI) $(DEPENDS_ON_LIBJAYLINK))
 endif
 
 ifeq ($(HAS_LINUX_MTD), no)
@@ -289,7 +332,7 @@
 
 ifeq ($(TARGET_OS), Android)
 # Android on x86 (currently) does not provide raw PCI port I/O operations.
-$(call mark_unsupported,CONFIG_RAYER_SPI)
+$(call mark_unsupported,$(DEPENDS_ON_X86_PORT_IO))
 endif
 
 # Disable the internal programmer on unsupported architectures (everything but x86 and mipsel)
@@ -323,18 +366,15 @@
 # PCI port I/O support is unimplemented on PPC/MIPS/SPARC and unavailable on ARM.
 # Right now this means the drivers below only work on x86.
 ifneq ($(ARCH), x86)
-$(call mark_unsupported,CONFIG_NIC3COM CONFIG_NICREALTEK CONFIG_NICNATSEMI)
-$(call mark_unsupported,CONFIG_RAYER_SPI CONFIG_ATAHPT CONFIG_ATAPROMISE)
-$(call mark_unsupported,CONFIG_SATAMV)
+$(call mark_unsupported,$(DEPENDS_ON_X86_MSR))
+$(call mark_unsupported,$(DEPENDS_ON_X86_PORT_IO))
 endif
 
 # Additionally disable all drivers needing raw access (memory, PCI, port I/O)
 # on architectures with unknown raw access properties.
 # Right now those architectures are alpha hppa m68k sh s390
 ifneq ($(ARCH), $(filter $(ARCH), x86 mips ppc arm sparc arc))
-$(call mark_unsupported,CONFIG_GFXNVIDIA CONFIG_SATASII CONFIG_ATAVIA)
-$(call mark_unsupported,CONFIG_DRKAISER CONFIG_NICINTEL CONFIG_NICINTEL_SPI)
-$(call mark_unsupported,CONFIG_NICINTEL_EEPROM CONFIG_OGP_SPI CONFIG_IT8212)
+$(call mark_unsupported,$(DEPENDS_ON_RAW_MEM_ACCESS))
 endif
 
 ifeq ($(TARGET_OS), $(filter $(TARGET_OS), Linux Darwin NetBSD OpenBSD))