2
# ----------------------------------------------------------------------------
4
# - afnix compiler version detection -
5
# ----------------------------------------------------------------------------
6
# - This program is free software; you can redistribute it and/or modify -
7
# - it provided that this copyright notice is kept intact. -
9
# - This program is distributed in the hope that it will be useful, but -
10
# - without any warranty; without even the implied warranty of -
11
# - merchantability or fitness for a particular purpose. In not event shall -
12
# - the copyright holder be liable for any direct, indirect, incidental or -
13
# - special damages arising in any way out of the use of this software. -
14
# ----------------------------------------------------------------------------
15
# - copyright (c) 1999-2015 amaury darsch -
16
# ----------------------------------------------------------------------------
18
# ----------------------------------------------------------------------------
19
# - set default variables -
20
# ----------------------------------------------------------------------------
33
# ----------------------------------------------------------------------------
34
# - local function always make life easier -
35
# ----------------------------------------------------------------------------
37
# print a usage message
39
echo "usage: afnix-vcomp [options]"
40
echo " -h print this help message"
41
echo " --compiler set the compiler name"
45
# print an error message
51
# get the platform and the ccname
53
# get the platform name
54
basdir=`dirname $prgnam`
55
pltexe="$basdir/afnix-guess"
57
# get the compiler name if not defined
58
if test -z "$ccname" ; then
59
qryexe="$basdir/afnix-query"
60
ccname=`$qryexe --default=gcc compiler`
64
# get the compiler makefile
67
if test "$ccname" = "gcc" ; then
71
if test "$ccname" = "g++" ; then
75
if test "$ccname" = "clang"; then
79
if test "$ccname" = "clang++"; then
84
# get the compiler version
87
if test "$ccname" = "gcc" ; then
89
vers=`gcc -dumpversion`
97
if test "$ccname" = "g++" ; then
99
vers=`g++ -dumpversion`
107
if test "$ccname" = "clang" ; then
109
vers=`clang -dumpversion`
116
if test "$ccname" = "clang++" ; then
118
vers=`clang++ -dumpversion`
126
# ----------------------------------------------------------------------------
127
# - parse options - this is where we really start -
128
# ----------------------------------------------------------------------------
130
# get the default settings
137
# assign the previous option argument
138
if test -n "$preopt"; then
139
eval "$preopt=\$nxtopt"
146
-*=*) argopt=`echo "$nxtopt" | sed 's/[-_a-zA-Z0-9]*=//'`;;
150
# process options now
152
-h | --help) usage ;;
154
--compiler) preopt=ccname;;
155
--compiler=*) ccname="$argopt";;
157
*) error "illegal option $nxtopt";;
161
# get the cc make/version
164
# check for final result
165
if test -z "$ccmake" ; then
166
error "cannot find compile makefile for $ccname"
168
if test -z "$ccvers" ; then
169
error "cannot find version for compiler $ccname"
173
result=${ccmake}${ccvers}