File: ccver.sh

package info (click to toggle)
kamailio 4.2.0-2+deb8u3
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 56,276 kB
  • sloc: ansic: 552,836; xml: 166,484; sh: 8,659; makefile: 7,676; sql: 6,235; perl: 3,487; yacc: 3,428; python: 1,457; cpp: 1,219; php: 1,047; java: 449; pascal: 194; cs: 40; awk: 27
file content (83 lines) | stat: -rwxr-xr-x 1,399 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/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
		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/'`
	elif echo "$FULLVER"|grep Sun >/dev/null
	then
		NAME=suncc
		VER=`echo "$FULLVER"|head -n 1| \
				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
		VER=`echo "$FULLVER"|head -n 1| \
				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"
	MAJOR_VER="unknown"
fi


echo "$NAME $VER $MAJOR_VER"