#!/bin/sh
# ----------------------------------------------------------------------------
# - aleph-vcomp                                                              -
# - aleph compiler version detection                                         -
# ----------------------------------------------------------------------------
# - This program is  free software;  you can  redistribute it and/or  modify -
# - it provided that this copyright notice is kept intact.                   -
# -                                                                          -
# - This  program  is  distributed in the hope  that it  will be useful, but -
# - without  any   warranty;  without  even   the   implied    warranty   of -
# - merchantability  or fitness for a particular purpose. In not event shall -
# - the copyright holder be  liable for  any direct, indirect, incidental or -
# - special damages arising in any way out of the use of this software.      -
# ----------------------------------------------------------------------------
# - copyright (c) 1999-2003 amaury darsch                                    -
# ----------------------------------------------------------------------------

# ----------------------------------------------------------------------------
# - set default variables                                                    -
# ----------------------------------------------------------------------------

# result version
version=
# the compiler to check
compiler=gcc

# this function detect the gcc version to apply
detect_gcc () {
    # get gcc version 
    vers="`gcc -v 2>&1 | grep '^gcc version' | awk '{print $3}'`"
    case $vers in
    2.*) version=2;;
    3.*) version=3;;
    *) version=;;
    esac
}

# check for one argument
if [ "$1" != "" ]; then
    compiler="$1"
fi

# check compiler
case $compiler in
gcc) detect_gcc;;
*)    version=;;
esac

if [ "$version" = "" ]; then
    echo $compiler
else
    echo ${compiler}-${version}
fi
exit 0
