modules/ims_qos: added patch for flow-description bug when request originates from...
[sip-router] / ccver.sh
1 #!/bin/sh
2
3 #$Id$
4 #
5 # finds CC version and prints it in the following format:
6 # compiler_name version major_version
7 #
8
9
10
11 if [ $# -lt 1 ]
12 then 
13         echo "Error: you must specify the compiler name" 1>&2
14         exit 1
15 fi
16
17 if [ "$1" = "-h" ]
18 then
19         echo "Usage: "
20         echo "      $0 compiler_name"
21         exit 1
22 fi
23
24
25 CC=$1
26
27 if  which $CC >/dev/null
28 then
29         (test ! -x `which $CC`) && echo "Error: $CC not executable" 1>&2 && exit 1
30 else
31         echo "Error: $CC not found or not executable" 1>&2
32         exit 1 
33 fi
34
35
36 if $CC -v 2>/dev/null 1>/dev/null
37 then
38         FULLVER=`$CC -v 2>&1` 
39 else
40         FULLVER=`$CC -V 2>&1`
41 fi
42
43
44
45 if [ -n "$FULLVER" ]
46 then
47         # check if gcc
48         if echo "$FULLVER"|grep gcc >/dev/null
49         then
50                 NAME=gcc
51                 VER=`$CC --version|head -n 1| \
52                                 sed -e 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/'\
53                                     -e 's/^[^.0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/'`
54         elif echo "$FULLVER"|grep Sun >/dev/null
55         then
56                 NAME=suncc
57                 VER=`echo "$FULLVER"|head -n 1| \
58                                 sed -e 's/.*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/'`
59         elif echo "$FULLVER"|grep "Intel(R) C++ Compiler" >/dev/null
60         then
61                 NAME=icc
62                 VER=`echo "$FULLVER"|head -n 1| \
63                                 sed -e 's/.*Version \([0-9]\.[0-9]\.[0-9]*\).*/\1/' ` 
64         fi
65         
66         # find major ver
67         if [  -n "$VER"  -a -z "$MAJOR_VER" ]
68         then
69                 MAJOR_VER=`echo "$VER" |cut -d. -f1`
70         fi
71 fi      
72
73
74 #unknown
75 if [ -z "$NAME" ]
76 then
77         NAME="unknown"
78         VER="unknown"
79         MAJOR_VER="unknown"
80 fi
81
82
83 echo "$NAME $VER $MAJOR_VER"