From 4988af8ca8f3323a5a6b63a0b83ebda1fc2d2a81 Mon Sep 17 00:00:00 2001 From: Arthur Heymans Date: Sun, 2 Apr 2017 23:21:53 +0200 Subject: [PATCH] util/superiotool: Check for libpci before builing Check is adapted from inteltool's Makefile. Change-Id: Ife01ef20d9284cb0a68719757856f9a66a4de452 Signed-off-by: Arthur Heymans Reviewed-on: https://review.coreboot.org/19074 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- util/superiotool/Makefile | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/util/superiotool/Makefile b/util/superiotool/Makefile index f6d9685585..f05e1f9d1f 100644 --- a/util/superiotool/Makefile +++ b/util/superiotool/Makefile @@ -60,7 +60,7 @@ LIBS += -lpciutils endif endif -all: $(PROGRAM) +all: pciutils $(PROGRAM) superiotool.o: *.c superiotool.h @@ -79,3 +79,34 @@ clean: distclean: clean .PHONY: all install clean distclean + +ifeq ($(CONFIG_PCI), yes) +define LIBPCI_TEST +/* Avoid a failing test due to libpci header symbol shadowing breakage */ +#define index shadow_workaround_index +#ifdef __NetBSD__ +#include +#else +#include +#endif +struct pci_access *pacc; +int main(int argc, char **argv) +{ + (void) argc; + (void) argv; + pacc = pci_alloc(); + return 0; +} +endef +export LIBPCI_TEST + +pciutils: + @printf "\nChecking for pciutils and zlib... " + @echo "$$LIBPCI_TEST" > .test.c + @$(CC) $(CFLAGS) .test.c -o .test $(LIBS) >/dev/null 2>&1 && \ + printf "found.\n" || ( printf "not found.\n\n"; \ + printf "Please install pciutils-devel and zlib-devel.\n"; \ + printf "See README for more information.\n\n"; \ + rm -f .test.c .test; exit 1) + @rm -rf .test.c .test .test.dSYM +endif