ccver.sh
3accd5b4
 #!/bin/sh
 
 #$Id$
 #
 # finds CC version and prints it in the following format:
 # compiler_name version major_version
 #
 
 
 
 if [ $# -lt 1 ]
 then 
 	echo "Error: you must specify the compiler name" 1>&2
 	exit 1
 fi
 
 if [ "$1" = "-h" ]
 then
 	echo "Usage: "
 	echo "      $0 compiler_name"
 	exit 1
 fi
 
 
 CC=$1
 
 if  which $CC >/dev/null
 then
 	(test ! -x `which $CC`) && echo "Error: $CC not executable" 1>&2 && exit 1
 else
 	echo "Error: $CC not found or not executable" 1>&2
 	exit 1 
 fi
 
 
 if $CC -v 2>/dev/null 1>/dev/null
 then
 	FULLVER=`$CC -v 2>&1` 
 else
 	FULLVER=`$CC -V 2>&1`
 fi
 
 
 
 if [ -n "$FULLVER" ]
 then
 	# check if gcc
 	if echo "$FULLVER"|grep gcc >/dev/null
 	then
 		NAME=gcc
194b6a35
 		VER=`$CC --version|head -n 1| \
 				sed -e 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/'\
 				    -e 's/^[^.0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/'`
3accd5b4
 	elif echo "$FULLVER"|grep Sun >/dev/null
 	then
 		NAME=suncc
194b6a35
 		VER=`echo "$FULLVER"|head -n 1| \
3accd5b4
 				sed -e 's/.*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/'`
 	elif echo "$FULLVER"|grep "Intel(R) C++ Compiler" >/dev/null
 	then
 		NAME=icc
194b6a35
 		VER=`echo "$FULLVER"|head -n 1| \
3accd5b4
 				sed -e 's/.*Version \([0-9]\.[0-9]\.[0-9]*\).*/\1/' ` 
 	fi
 	
 	# find major ver
 	if [  -n "$VER"  -a -z "$MAJOR_VER" ]
 	then
 		MAJOR_VER=`echo "$VER" |cut -d. -f1`
 	fi
 fi	
 
 
 #unknown
 if [ -z "$NAME" ]
 then
 	NAME="unknown"
 	VER="unknown"
53c7e0f1
 	MAJOR_VER="unknown"
3accd5b4
 fi
 
 
 echo "$NAME $VER $MAJOR_VER"