<div class="gmail_quote">2010/3/22 Carl-Daniel Hailfinger <span dir="ltr"><<a href="mailto:c-d.hailfinger.devel.2006@gmx.net">c-d.hailfinger.devel.2006@gmx.net</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div></div><div class="h5">On 01.03.2010 16:34, Carl-Daniel Hailfinger wrote:<br>
> On 28.02.2010 16:30, Idwer Vollering wrote:<br>
><br>
>> 2010/2/26 Carl-Daniel Hailfinger <<a href="mailto:c-d.hailfinger.devel.2006@gmx.net">c-d.hailfinger.devel.2006@gmx.net</a>><br>
>><br>
>><br>
>>> Idwer reported problems with the current libpci check on<br>
>>><br>
>>> FreeBSD 8.0-RELEASE i386<br>
>>><br>
>>> This is caused by a strict linker. Parsing linker error messages is an<br>
>>> exercise in futility, so I implemented fallback library detection with<br>
>>> $CC --print-file-name.<br>
>>> This fallback will fail on llvm-clang (llvm bug 5137), but such machines<br>
>>> hopefully have a more permissive linker and will never hit that code path.<br>
>>> The fallback will also fail on NetBSD where we should look for<br>
>>> libpciutils instead, but that hopefully doesn't have a strict linker<br>
>>> either.<br>
>>><br>
>>> Side note: The configure checks in the Makefile are now so unwieldy that<br>
>>> a separate configure script will definitely improve readability.<br>
>>><br>
>>> Signed-off-by: Carl-Daniel Hailfinger <<a href="mailto:c-d.hailfinger.devel.2006@gmx.net">c-d.hailfinger.devel.2006@gmx.net</a>><br>
>>><br>
>>><br>
>>><br>
>> $ gmake<br>
>> Checking for a C compiler... found.<br>
>> Checking for libpci headers... found.<br>
>> Checking for libpci (method 1)... not found.<br>
>> Checking for dynamic libpci (method 2)... not found.<br>
>> not found.<br>
>><br>
>> Please install libpci (package pciutils).<br>
>> See README for more information.<br>
>><br>
>> unavailable.<br>
>><br>
>> Please install libpci (package pciutils).<br>
>> See README for more information.<br>
>><br>
>><br>
><br>
> Ouch. Turns out the patch had one error message too many, a missing<br>
> semicolon and missing LDFLAGS in some CC calls.<br>
> New version<br>
> .<br>
> Idwer reported problems with the current libpci check on<br>
> FreeBSD 8.0-RELEASE i386<br>
> This is caused by a strict linker. Parsing linker error messages is an<br>
> exercise in futility, so I implemented fallback library detection with<br>
> $CC --print-file-name.<br>
> This fallback may cause false positives/negatives on llvm-clang (llvm<br>
> bug 5137), but such machines hopefully have a more permissive linker and<br>
> will never hit that code path.<br>
> The fallback will be unreliable on NetBSD where we should look for<br>
> libpciutils instead, but that hopefully doesn't have a strict linker<br>
> either. A fix is easy (replace libpci with PCI_LIB_NAME), but outside<br>
> the scope of this patch.<br>
> Tested with error injection at various levels.<br>
<br>
</div></div>Turns out that --print-file-name is totally useless for libraries<br>
outside the standard hardcoded builtin gcc search path. Oh well. Back to<br>
some really simple code which should even work. Nice benefit is that we<br>
use the correct libpci on NetBSD for the check.<br>
<div class="im"><br>
Signed-off-by: Carl-Daniel Hailfinger <<a href="mailto:c-d.hailfinger.devel.2006@gmx.net">c-d.hailfinger.devel.2006@gmx.net</a>><br></div></blockquote><div><br><span class="il">Acked</span>-<span class="il">by</span>: Idwer Vollering <<a href="mailto:vidwer@gmail.com">vidwer@gmail.com</a>> <br>
</div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">
<br>
Index: flashrom-libpci_robust_detection/Makefile<br>
===================================================================<br>
</div>--- flashrom-libpci_robust_detection/Makefile   (Revision 964)<br>
<div class="im">+++ flashrom-libpci_robust_detection/Makefile   (Arbeitskopie)<br>
</div>@@ -279,26 +279,17 @@<br>
<div class="im">                echo "Please install libpci headers (package pciutils-devel)."; \<br>
                echo "See README for more information."; echo;                  \<br>
                rm -f .test.c .test.o; exit 1)<br>
-       @printf "Checking for libpci... "<br>
</div>-       @$(shell ( echo "#include <pci/pci.h>";            \<br>
<div class="im">-                  echo "int main(int argc, char **argv)"; \<br>
-                  echo "{ return 0; }"; ) > .test1.c )<br>
-       @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test1.c -o .test1 -lpci $(LIBS) >/dev/null 2>&1 &&     \<br>
-               echo "found." || ( echo "not found."; echo;                             \<br>
-               echo "Please install libpci (package pciutils).";                       \<br>
-               echo "See README for more information."; echo;                          \<br>
-               rm -f .test1.c .test1; exit 1)<br>
</div>-       @printf "Checking if libpci is sufficient... "<br>
+       @printf "Checking if libpci is present and sufficient... "<br>
<div class="im">        @printf "" > .libdeps<br>
-       @$(CC) $(LDFLAGS) .test.o -o .test -lpci $(LIBS) >/dev/null 2>&1 &&                             \<br>
+       @$(CC) $(LDFLAGS) .test.o -o .test $(LIBS) >/dev/null 2>&1 &&                           \<br>
                echo "yes." || ( echo "no.";                                                    \<br>
-               printf "Checking if libz is present and supplies all needed symbols...";        \<br>
-               $(CC) $(LDFLAGS) .test.o -o .test -lpci -lz $(LIBS) >/dev/null 2>&1 &&          \<br>
</div>+               printf "Checking if libz+libpci are present and sufficient..."; \<br>
<div class="im">+               $(CC) $(LDFLAGS) .test.o -o .test $(LIBS) -lz >/dev/null 2>&1 &&                \<br>
                ( echo "yes."; echo "NEEDLIBZ := yes" > .libdeps ) || ( echo "no."; echo;       \<br>
-               echo "Please install libz.";                    \<br>
</div>+               echo "Please install libpci (package pciutils) and/or libz.";                   \<br>
<div class="im">                echo "See README for more information."; echo;                          \<br>
</div>                rm -f .test.c .test.o .test; exit 1) )<br>
-       @rm -f .test.c .test.o .test .test1.c .test1<br>
+       @rm -f .test.c .test.o .test<br>
 else<br>
 pciutils: compiler<br>
        @printf "" > .libdeps<br>
<div><div></div><div class="h5"><br>
<br>
--<br>
"I do consider assignment statements and pointer variables to be among<br>
computer science's most valuable treasures."<br>
-- Donald E. Knuth<br>
<br>
</div></div></blockquote></div><br>