Makefile: Use pciutils/pci.h only for older NetBSD packages

Fixes building on newer NetBSD.

Change-Id: Ie049e485fa25f5da6a372e8ddf87783dd909c3fa
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/70927
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/Makefile b/Makefile
index 0cea6b7..fa4bbbd 100644
--- a/Makefile
+++ b/Makefile
@@ -126,7 +126,9 @@
 endif
 
 ifeq ($(TARGET_OS), NetBSD)
-override CPPFLAGS += -I/usr/pkg/include
+# Needs special `pciutils/pci.h` for older NetBSD packages
+PCIUTILS_PCI_H := $(shell [ -f /usr/pkg/include/pciutils/pci.h ] && echo -DPCIUTILS_PCI_H)
+override CPPFLAGS += -I/usr/pkg/include $(PCIUTILS_PCI_H)
 override LDFLAGS += -L/usr/pkg/lib
 endif
 
@@ -1206,7 +1208,7 @@
 define LIBPCI_TEST
 /* Avoid a failing test due to libpci header symbol shadowing breakage */
 #define index shadow_workaround_index
-#if !defined __NetBSD__
+#if !defined PCIUTILS_PCI_H
 #include <pci/pci.h>
 #else
 #include <pciutils/pci.h>
@@ -1225,7 +1227,7 @@
 define PCI_GET_DEV_TEST
 /* Avoid a failing test due to libpci header symbol shadowing breakage */
 #define index shadow_workaround_index
-#if !defined __NetBSD__
+#if !defined PCIUTILS_PCI_H
 #include <pci/pci.h>
 #else
 #include <pciutils/pci.h>