diff --git a/Makefile b/Makefile index fa67b731e..4b93bedff 100644 --- a/Makefile +++ b/Makefile @@ -230,6 +230,8 @@ FEATURE_CFLAGS += -D'PRINT_WIKI_SUPPORT=1' CLI_OBJS += print_wiki.o endif +FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "UTSNAME := yes" .features && printf "%s" "-D'HAVE_UTSNAME=1'") + # We could use PULLED_IN_LIBS, but that would be ugly. FEATURE_LIBS += $(shell LC_ALL=C grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz") @@ -308,12 +310,29 @@ features: compiler @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest $(FTDILIBS) $(LIBS) >/dev/null 2>&1 && \ ( echo "found."; echo "FTDISUPPORT := yes" >> .features.tmp ) || \ ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp ) + @printf "Checking for utsname support... " + @$(shell ( echo "#include "; \ + echo "struct utsname osinfo;"; \ + echo "int main(int argc, char **argv)"; \ + echo "{ uname (&osinfo); return 0; }"; ) > .featuretest.c ) + @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest >/dev/null 2>&1 && \ + ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) || \ + ( echo "not found."; echo "UTSNAME := no" >> .features.tmp ) @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features @rm -f .featuretest.c .featuretest else features: compiler @echo "FEATURES := yes" > .features.tmp + @printf "Checking for utsname support... " + @$(shell ( echo "#include "; \ + echo "struct utsname osinfo;"; \ + echo "int main(int argc, char **argv)"; \ + echo "{ uname (&osinfo); return 0; }"; ) > .featuretest.c ) + @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest >/dev/null 2>&1 && \ + ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) || \ + ( echo "not found."; echo "UTSNAME := no" >> .features.tmp ) @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features + @rm -f .featuretest.c .featuretest endif install: $(PROGRAM) diff --git a/flashrom.c b/flashrom.c index f5c0721f9..2450dee45 100644 --- a/flashrom.c +++ b/flashrom.c @@ -27,6 +27,9 @@ #include #include #include +#if HAVE_UTSNAME == 1 +#include +#endif #include "flash.h" #include "flashchips.h" @@ -1133,9 +1136,44 @@ void list_programmers(char *delim) printf("\n"); } +void print_sysinfo(void) +{ +#if HAVE_UTSNAME == 1 + struct utsname osinfo; + uname(&osinfo); + + msg_ginfo(" on %s %s (%s)", osinfo.sysname, osinfo.release, + osinfo.machine); +#else + msg_ginfo(" on unknown machine"); +#endif + msg_ginfo(", built with"); +#if NEED_PCI == 1 +#ifdef PCILIB_VERSION + msg_ginfo(" libpci %s,", PCILIB_VERSION); +#else + msg_ginfo(" unknown PCI library,"); +#endif +#endif +#ifdef __clang__ + msg_ginfo(" LLVM %i/clang %i", __llvm__, __clang__); +#elif defined(__GNUC__) + msg_ginfo(" GCC"); +#ifdef __VERSION__ + msg_ginfo(" %s", __VERSION__); +#else + msg_ginfo(" unknown version"); +#endif +#else + msg_ginfo(" unknown compiler"); +#endif + msg_ginfo("\n"); +} + void print_version(void) { - printf("flashrom v%s\n", flashrom_version); + printf("flashrom v%s", flashrom_version); + print_sysinfo(); } int selfcheck(void)