#!/bin/sh

HOST_SYSTEM=`uname -s`

#check the parameters:

if test $1 != "-"; then
  COMPILER=$1
	shift
fi

if test $1 != "-"; then
  FLAGS=$1
	shift
fi

if test $1 = "-"; then
	shift
fi

CXX=
CC=
CXXFLAGS=
CFLAGS=

#prepare the operation specific parameters
#  - standard compiler
#  - standard compiler flags
#  - location of additional libraries

case $HOST_SYSTEM in
		
	Linux*)
		COMPILER=${COMPILER-GNU}
		FLAGS=${FLAGS-"-O2 -w"}
		;;

  OSF*)
		COMPILER=${COMPILER-COMPAQ}
		FLAGS=${FLAGS-"-O2 -w"}
    ;;

esac

#prepare the compiler specific variables
#  - C-compiler
#  - C++-compiler
#  - compiler flags

case $COMPILER in

	GNU | gnu | gcc)
		CXX=g++
		CC=gcc
		CXXFLAGS=$FLAGS
		CFLAGS=$FLAGS
		;;
		
	COMPAQ | compaq | cxx)
		CXX=cxx
		CC=cc
		CXXFLAGS=$FLAGS
		CFLAGS=$FLAGS
		;;
		
	INTEL | intel | icc)
		CXX=icc
		CC=icc
		CXXFLAGS=$FLAGS
		CFLAGS=$FLAGS
		;;
esac

export CXX CC CXXFLAGS CFLAGS

echo "Starting configuration of the package with the following parameters:"
echo "----------------------------------------------------------------------"
echo "  - C++ compiler = $CXX"
echo "  - C   compiler = $CC"
echo "  - C++ flags    = $CXXFLAGS"
echo "  - C   flags    = $CFLAGS"
echo 
echo "./configure $*"
echo 

#call ./configure
./configure $*
