#!/bin/bash
#
# Call this with the CMTCONFIG as first argument and
# it returns the exact version of the compiler that
# is picked up for it.
#
[ $# -eq 1 ] || exit 1

PATH=/bin:/usr/bin
unset LD_LIBRARY_PATH PYTHONPATH PYTHONHOME

source $(dirname $(readlink -f $0))/setup.sh $1 2> /dev/null

case $1 in
    *-gcc*)
        version=$(command -v g++ | sed -e 's;.*/gcc/;;' -e 's;-.*$;;')
        ;;
    *-clang*)
        unalias clang++
        version=$(command -v clang++ | sed -e 's;.*/clang/;;' -e 's;-.*$;;')
        ;;
    *)
        echo -n "unkown"
        exit 1
esac

echo -n $version
