2010/3/24 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><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
New version: Improve reliability of utsname detection.<br>
<br>
Add runtime and build environment info to the flashrom version message.<br>
This patch uses code from Idwer Vollering and Maciej Pijanka.<br>
<div class="im">I've added Makefile support and compiler version printing and<br>
restructured the code heavily.<br>
The code prints runtime system information and buildtime libpci<br>
information (I couldn't find any runtime libpci version function). Due<br>
to our ability to cross-compile flashrom, buildtime system information<br>
from "uname -mrs" doesn't help diagnosing any problems. That's why only<br>
libpci and gcc are buildtime info, and the rest is runtime info.<br>
<br>
Examples:<br>
With PCI support:<br>
</div><div class="im">flashrom v0.9.1-r971 on Linux 2.6.22.19-0.2-default (i686), built with libpci 2.2.6, GCC 4.2.1 (SUSE Linux)<br>
</div>flashrom v0.9.1-r971 on Linux 2.6.22.19-0.2-default (i686), built with libpci 2.2.6, LLVM 1/clang 1<br>
flashrom v0.9.1-r972 on Linux 2.6.27.29-0.1-default (x86_64), built with libpci 3.0.1, GCC 4.3.2 [gcc-4_3-branch revision 141291]<br>
<br>
Without PCI support:<br>
flashrom v0.9.1-r971 on Linux 2.6.22.19-0.2-default (i686), built with GCC 4.2.1 (SUSE Linux)<br>
flashrom v0.9.1-r971 on Linux 2.6.22.19-0.2-default (i686), built with LLVM 1/clang 1<br>
flashrom v0.9.1-r972 on Linux 2.6.27.29-0.1-default (x86_64), built with GCC 4.3.2 [gcc-4_3-branch revision 141291]<br>
<div class="im"><br>
Reviews appreciated, especially about the compiler part. I think this<br>
can be valuable (e.g. if someone compiles with clang and triggers the<br>
clang/flashrom miscompile), but I'm unsure if/how this works on Windows<br>
and DOS. I tried to make it non-explosive, but...<br>
<br>
<br>
Output from "flashrom --version" for non-Linux platforms and unusual<br>
compilers would be appreciated.<br></div></blockquote><div><br>flashrom v0.9.1-r973 on CYGWIN_NT-5.1 1.7.1(0.218/5/3) (i686), built with GCC 4.3.4 20090804 (release) 1<br><br>flashrom v0.9.1-r973 on FreeBSD 8.0-RELEASE-p2 (i386), built with libpci 3.1.7, GCC 4.2.1 20070719  [FreeBSD]<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>
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>Signed-off-by: Idwer Vollering <<a href="mailto:vidwer@gmail.com">vidwer@gmail.com</a>><br>
</div><div> </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">
</div><div class="im">Index: flashrom-uname/Makefile<br>
===================================================================<br>
--- flashrom-uname/Makefile     (Revision 971)<br>
+++ flashrom-uname/Makefile     (Arbeitskopie)<br>
@@ -230,6 +230,8 @@<br>
 CLI_OBJS += print_wiki.o<br>
 endif<br>
<br>
+FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "UTSNAME := yes" .features && printf "%s" "-D'HAVE_UTSNAME=1'")<br>
+<br>
 # We could use PULLED_IN_LIBS, but that would be ugly.<br>
 FEATURE_LIBS += $(shell LC_ALL=C grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")<br>
<br>
@@ -308,12 +310,29 @@<br>
        @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest $(FTDILIBS) $(LIBS) >/dev/null 2>&1 &&   \<br>
                ( echo "found."; echo "FTDISUPPORT := yes" >> .features.tmp ) ||        \<br>
                ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp )<br>
+       @printf "Checking for utsname support... "<br>
+       @$(shell ( echo "#include <sys/utsname.h>";                \<br>
+                  echo "struct utsname osinfo;";          \<br>
+                  echo "int main(int argc, char **argv)"; \<br>
+                  echo "{ uname (&osinfo); return 0; }"; ) > .featuretest.c )<br>
</div>+       @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest >/dev/null 2>&1 &&       \<br>
<div class="im">+               ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) ||    \<br>
+               ( echo "not found."; echo "UTSNAME := no" >> .features.tmp )<br>
        @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features<br>
        @rm -f .featuretest.c .featuretest<br>
 else<br>
 features: compiler<br>
        @echo "FEATURES := yes" > .features.tmp<br>
+       @printf "Checking for utsname support... "<br>
+       @$(shell ( echo "#include <sys/utsname.h>";                \<br>
+                  echo "struct utsname osinfo;";          \<br>
+                  echo "int main(int argc, char **argv)"; \<br>
+                  echo "{ uname (&osinfo); return 0; }"; ) > .featuretest.c )<br>
</div>+       @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest >/dev/null 2>&1 &&       \<br>
<div class="im">+               ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) ||    \<br>
+               ( echo "not found."; echo "UTSNAME := no" >> .features.tmp )<br>
        @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features<br>
+       @rm -f .featuretest.c .featuretest<br>
 endif<br>
<br>
 install: $(PROGRAM)<br>
Index: flashrom-uname/flashrom.c<br>
===================================================================<br>
--- flashrom-uname/flashrom.c   (Revision 971)<br>
+++ flashrom-uname/flashrom.c   (Arbeitskopie)<br>
@@ -27,6 +27,9 @@<br>
 #include <string.h><br>
 #include <stdlib.h><br>
 #include <getopt.h><br>
+#if HAVE_UTSNAME == 1<br>
+#include <sys/utsname.h><br>
+#endif<br>
 #include "flash.h"<br>
 #include "flashchips.h"<br>
<br>
</div>@@ -1133,9 +1136,44 @@<br>
<div class="im">        printf("\n");<br>
 }<br>
<br>
+void print_sysinfo(void)<br>
+{<br>
+#if HAVE_UTSNAME == 1<br>
+       struct utsname osinfo;<br>
+       uname(&osinfo);<br>
+<br>
+       msg_ginfo(" on %s %s (%s)", osinfo.sysname, osinfo.release,<br>
+                 osinfo.machine);<br>
+#else<br>
+       msg_ginfo(" on unknown machine");<br>
+#endif<br>
</div>+       msg_ginfo(", built with");<br>
<div class="im">+#if NEED_PCI == 1<br>
+#ifdef PCILIB_VERSION<br>
</div>+       msg_ginfo(" libpci %s,", PCILIB_VERSION);<br>
+#else<br>
+       msg_ginfo(" unknown PCI library,");<br>
+#endif<br>
+#endif<br>
+#ifdef __clang__<br>
+       msg_ginfo(" LLVM %i/clang %i", __llvm__, __clang__);<br>
+#elif defined(__GNUC__)<br>
<div class="im">+       msg_ginfo(" GCC");<br>
+#ifdef __VERSION__<br>
+       msg_ginfo(" %s", __VERSION__);<br>
+#else<br>
+       msg_ginfo(" unknown version");<br>
+#endif<br>
+#else<br>
+       msg_ginfo(" unknown compiler");<br>
+#endif<br>
+       msg_ginfo("\n");<br>
+}<br>
+<br>
 void print_version(void)<br>
 {<br>
-       printf("flashrom v%s\n", flashrom_version);<br>
+       printf("flashrom v%s", flashrom_version);<br>
+       print_sysinfo();<br>
 }<br>
<br>
 int selfcheck(void)<br>
<br>
<br>
--<br>
</div><div><div></div><div class="h5"><a href="http://www.hailfinger.org/" target="_blank">http://www.hailfinger.org/</a><br>
<br>
<br>
_______________________________________________<br>
flashrom mailing list<br>
<a href="mailto:flashrom@flashrom.org">flashrom@flashrom.org</a><br>
<a href="http://www.flashrom.org/mailman/listinfo/flashrom" target="_blank">http://www.flashrom.org/mailman/listinfo/flashrom</a><br>
</div></div></blockquote></div><br>