Idwer reported problems with the current libpci check on
FreeBSD 8.0-RELEASE i386
This is caused by a strict linker. Parsing linker error messages is an exercise in futility, so I implemented fallback library detection with $CC --print-file-name. This fallback will fail on llvm-clang (llvm bug 5137), but such machines hopefully have a more permissive linker and will never hit that code path. The fallback will also fail on NetBSD where we should look for libpciutils instead, but that hopefully doesn't have a strict linker either.
Side note: The configure checks in the Makefile are now so unwieldy that a separate configure script will definitely improve readability.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: flashrom-libpci_robust_detection/Makefile =================================================================== --- flashrom-libpci_robust_detection/Makefile (Revision 916) +++ flashrom-libpci_robust_detection/Makefile (Arbeitskopie) @@ -251,21 +251,30 @@ 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 for libpci... " + @printf "Checking for libpci (method 1)... " @$(shell ( echo "#include <pci/pci.h>"; \ echo "int main(int argc, char **argv)"; \ echo "{ return 0; }"; ) > .test1.c ) - @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test1.c -o .test1 -lpci $(LIBS) >/dev/null 2>&1 && \ - echo "found." || ( echo "not found."; echo; \ - echo "Please install libpci (package pciutils)."; \ - echo "See README for more information."; echo; \ - rm -f .test1.c .test1; exit 1) + @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test1.c -o .test1 $(LIBS) >/dev/null 2>&1 && \ + echo "found." || ( echo "not found."; \ + $(CC) --print-file-name=libpci.so >/dev/null 2>&1 && ( \ + printf "Checking for dynamic libpci (method 2)... "; \ + $(CC) --print-file-name=libpci.so 2>/dev/null | grep -q / && \ + echo "found." || ( echo "not found."; \ + printf "Checking for static libpci (method 2)... " \ + $(CC) --print-file-name=libpci.a 2>/dev/null | grep -q / && \ + echo "found." || ( echo "not found."; echo; \ + echo "Please install libpci (package pciutils)."; \ + echo "See README for more information."; echo; \ + rm -f .test1.c .test1; exit 1) ) ) || ( echo "unavailable."; echo; \ + echo "Please install libpci (package pciutils)."; \ + echo "See README for more information."; echo; )) @printf "Checking if libpci is sufficient... " @printf "" > .libdeps - @$(CC) $(LDFLAGS) .test.o -o .test -lpci $(LIBS) >/dev/null 2>&1 && \ + @$(CC) $(LDFLAGS) .test.o -o .test $(LIBS) >/dev/null 2>&1 && \ echo "yes." || ( echo "no."; \ printf "Checking if libz is present and supplies all needed symbols..."; \ - $(CC) $(LDFLAGS) .test.o -o .test -lpci -lz $(LIBS) >/dev/null 2>&1 && \ + $(CC) $(LDFLAGS) .test.o -o .test $(LIBS) -lz >/dev/null 2>&1 && \ ( echo "yes."; echo "NEEDLIBZ := yes" > .libdeps ) || ( echo "no."; echo; \ echo "Please install libz."; \ echo "See README for more information."; echo; \