$OpenBSD$
--- Makefile.orig	Thu Jun 24 22:09:19 2010
+++ Makefile	Thu Jun 24 22:22:14 2010
@@ -48,6 +48,10 @@ ifeq ($(OS_ARCH), FreeBSD)
 CPPFLAGS += -I/usr/local/include
 LDFLAGS += -L/usr/local/lib
 endif
+ifeq ($(OS_ARCH), OpenBSD)
+CPPFLAGS += -I/usr/local/include
+LDFLAGS += -L/usr/local/lib
+endif
 ifeq ($(OS_ARCH), DOS)
 EXEC_SUFFIX := .exe
 CPPFLAGS += -I../libgetopt -I../libpci/include
@@ -259,9 +263,13 @@ ifeq ($(OS_ARCH), DOS)
 LIBS += ../libpci/lib/libpci.a
 else
 LIBS += -lpci
+ifeq ($(OS_ARCH), OpenBSD)
+# For (i386|amd64)_iopl(2).
+LIBS += -l$(shell uname -m)
 endif
 endif
 endif
+endif
 
 ifeq ($(CONFIG_PRINT_WIKI), yes)
 FEATURE_CFLAGS += -D'CONFIG_PRINT_WIKI=1'
@@ -310,7 +318,9 @@ compiler: featuresavailable
 ifeq ($(CHECK_LIBPCI), yes)
 pciutils: compiler
 	@printf "Checking for libpci headers... "
-	@$(shell ( echo "#include <pci/pci.h>";		   \
+	@# Avoid a failing test due to libpci header symbol shadowing breakage
+	@$(shell ( echo "#define index shadow_workaround_index"; \
+		   echo "#include <pci/pci.h>";		   \
 		   echo "struct pci_access *pacc;";	   \
 		   echo "int main(int argc, char **argv)"; \
 		   echo "{ pacc = pci_alloc(); return 0; }"; ) > .test.c )
