diff options
author | Matt Turner <mattst88@gmail.com> | 2008-11-11 21:27:09 +0000 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2008-11-11 21:27:09 +0000 |
commit | 91b4edf69e5adf9c40edcaff38b880218b7b0d9d (patch) | |
tree | 85b654192fa2ce167f4899f6f0a4ca14b1acdb13 /sysinfo.sh |
Initial Import
git-svn-id: svn://mattst88.com/svn/cleanbench/trunk@1 0d43b9a7-5ab2-4d7b-af9d-f64450cef757
Diffstat (limited to 'sysinfo.sh')
-rwxr-xr-x | sysinfo.sh | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/sysinfo.sh b/sysinfo.sh new file mode 100755 index 0000000..57754fe --- /dev/null +++ b/sysinfo.sh @@ -0,0 +1,78 @@ +#!/bin/sh + +# the arguments of this script are the compiler name and flags + +# try to solve a chicken-and-egg problem on SunOS +# ucb's test program does not handle -L like the other test programs +# let's try to find another implementation +if test -x /bin/test; then + TEST=/bin/test; +else + if test -x /usr/bin/test; then + TEST=/usr/bin/test; + else + # cross your fingers that it's not like ucb test + TEST=test; + fi +fi + +compiler=`echo $* | sed -e 's/-static//g' -e 's/-Bstatic//g'` +if $TEST `basename $1` = "gcc" && ($compiler -v) >/dev/null 2>&1 ; then +# Cygwin writes more than one line with "version" in it + gccversion=`$compiler -v 2>&1 | sed -e "/version/!d" | tail -n 1` +else + gccversion="$1" +fi + +libcversion="" +if ($* hello.c -o hello) >/dev/null 2>&1; then + ldd_output=`(ldd hello) 2>&1` + libcversion=`echo $ldd_output | sed -e 's/.*static.*/static/' \ + -e 's/.*not a dynamic.*/static/'` + if $TEST "$libcversion" = "static" ; then + if ($compiler hello.c -o hello) >/dev/null 2>&1; then + if (ldd hello) >/dev/null 2>/dev/null; then + libcversion=`(ldd hello) 2>&1` + libcversion=`echo $libcversion | sed -e '/libc/!d'\ + -e 's/^[ ]*//' \ + -e 's/.*=>[ ][ ]*\([^ ]*\).*/\1/'` + # remember the current directory + current=`pwd` + while $TEST -L "$libcversion" && ! $TEST "$libcversion" = "" ; do + libcitself=`basename $libcversion` + libpath=`echo $libcversion | sed -e "s/$libcitself$//"` + if $TEST -d "$libpath" ; then + cd $libpath + fi + if ls $libcitself >/dev/null 2>/dev/null ; then + libcversion=`ls -l $libcitself | \ + sed -e 's/.*->[ ][ ]*\(.*\)$/\1/'` + else + # something must have gone wrong, let's bail out + libcversion="" + fi + done + # return to the current directory + cd $current + fi + fi + else + libcversion="" + fi +fi + +rm -f sysinfo.crm sysinfoc.c hello + +# this bombs out on Ultrix which expect "cut -d" + +compsystem=`uname -a | cut -b 1-78` +compdate=`date|cut -b1-55` + +# let's hope that ctrl-c is not part of any string here +# this also will barf later if " is in any of the strings + +for i in sysinfo.c sysinfoc.c ; do + sed -e "s%CCVERSION%$gccversion" -e "s%LIBCVERSION%$libcversion"\ + -e "s%SYSTEM%$compsystem" -e "s%DATE%$compdate"\ + ${i}.template > $i +done |