diff options
author | Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> | 2015-02-08 21:58:04 +0000 |
---|---|---|
committer | Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> | 2015-02-08 21:58:04 +0000 |
commit | 03d4faca7aed125d48c69dd50119e0ec0bfd5978 (patch) | |
tree | c983ef2d2c6f99c099cd4bad2bb517b44389aeb4 | |
parent | 2e0a0d55399da5fc1449459646e156f288498e29 (diff) | |
download | flashrom-03d4faca7aed125d48c69dd50119e0ec0bfd5978.zip flashrom-03d4faca7aed125d48c69dd50119e0ec0bfd5978.tar.gz |
Refine version check of libpci function pci_get_dev
The way more elegant check for the header fails unfortunately on CentOS 4.9
because PCI_LIB_VERSION is not defined at all although the domain parameter
is present. This patch jumps through the hoops via an additional check in the
Makefile to determine if the function accepts 5 parameters (new version) or
not (old version).
Corresponding to flashrom svn r1880.
Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
-rw-r--r-- | Makefile | 28 | ||||
-rw-r--r-- | board_enable.c | 2 |
2 files changed, 29 insertions, 1 deletions
@@ -713,6 +713,8 @@ endif ifeq ($(NEED_PCI), yes) CHECK_LIBPCI = yes FEATURE_CFLAGS += -D'NEED_PCI=1' +FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "OLD_PCI_GET_DEV := yes" .libdeps && printf "%s" "-D'OLD_PCI_GET_DEV=1'") + PROGRAMMER_OBJS += pcidev.o physmap.o hwaccess.o ifeq ($(TARGET_OS), NetBSD) # The libpci we want is called libpciutils on NetBSD and needs NetBSD libpci. @@ -842,6 +844,27 @@ int main(int argc, char **argv) endef export LIBPCI_TEST +define PCI_GET_DEV_TEST +/* Avoid a failing test due to libpci header symbol shadowing breakage */ +#define index shadow_workaround_index +#if !defined __NetBSD__ +#include <pci/pci.h> +#else +#include <pciutils/pci.h> +#endif +struct pci_access *pacc; +struct pci_dev *dev = {0}; +int main(int argc, char **argv) +{ + (void) argc; + (void) argv; + pacc = pci_alloc(); + dev = pci_get_dev(pacc, dev->domain, dev->bus, dev->dev, 1); + return 0; +} +endef +export PCI_GET_DEV_TEST + define LIBUSB0_TEST #include "platform.h" #if IS_WINDOWS @@ -869,6 +892,11 @@ ifeq ($(CHECK_LIBPCI), yes) echo "Please install libpci headers (package pciutils-devel)."; \ echo "See README for more information."; echo; \ rm -f .test.c .test.o; exit 1) + @printf "Checking version of pci_get_dev... " + @echo "$$PCI_GET_DEV_TEST" > .test.c + @$(CC) -c $(CPPFLAGS) $(CFLAGS) .test.c -o .test.o >/dev/null 2>&1 && \ + ( echo "new version (including PCI domain parameter)."; echo "OLD_PCI_GET_DEV := no" >> .libdeps ) || \ + ( echo "old version (without PCI domain parameter)."; echo "OLD_PCI_GET_DEV := yes" >> .libdeps ) @printf "Checking if libpci is present and sufficient... " @$(CC) $(LDFLAGS) .test.o -o .test$(EXEC_SUFFIX) $(LIBS) $(PCILIBS) >/dev/null && \ echo "yes." || ( echo "no."; \ diff --git a/board_enable.c b/board_enable.c index 66c587e..81dcfec 100644 --- a/board_enable.c +++ b/board_enable.c @@ -1047,7 +1047,7 @@ static int nvidia_mcp_gpio_set(int gpio, int raise) return -1; } -#if PCI_LIB_VERSION >= 0x020200 +#if !defined(OLD_PCI_GET_DEV) dev = pci_get_dev(pacc, dev->domain, dev->bus, dev->dev, 1); #else /* pciutils/libpci before version 2.2 is too old to support |