#!/bin/bash
P=scimarkc-install
DEFAULT_VERSION=2_1c
. $SHELLPACK_INCLUDE/common.sh
TIME_CMD=`which time`
if [ "$TIME_CMD" = "" ]; then
        TIMEFORMAT="%2Uuser %2Ssystem %Relapsed %P%%CPU"
        TIME_CMD="time"
fi
WEB_LOCATION="https://math.nist.gov/scimark2"
MIRROR_LOCATION="$WEBROOT/scimarkc"

# Basic argument parser
TASKSET_SERVER=
TASKSET_CLIENT=
SERVERSIDE_COMMAND=none
SERVERSIDE_NAME=`date +%Y%m%d-%H%M-%S`

while [ "$1" != "" ]; do
	case "$1" in
	-v)
		VERSION=$2
		shift 2
		;;
	--serverside-command)
		SERVERSIDE_COMMAND=$2
		shift 2
		;;
	--serverside-name)
		SERVERSIDE_NAME=$2
		shift 2
		;;
	--install-only)
		INSTALL_ONLY=yes
		shift
		;;
	--install-force)
		INSTALL_FORCE=yes
		shift
		;;
	*)
		echo Unrecognised option: $1
		shift
	esac
done
if [ "$TASKSET_SERVER" != "" ]; then
	echo TASKSET_SERVER: $TASKSET_SERVER
	echo TASKSET_CLIENT: $TASKSET_CLIENT
fi
if [ -z "$VERSION" ]; then
	VERSION=$DEFAULT_VERSION
fi

ZIPFILE="scimark${VERSION}.zip"
sources_fetch $WEB_LOCATION/$ZIPFILE $MIRROR_LOCATION/$ZIPFILE $SHELLPACK_SOURCES/$ZIPFILE
cd $SHELLPACK_SOURCES || die Sources directory does not exist
rm -rf scimarkc-${VERSION}-installed
mkdir scimarkc-${VERSION}-installed
cd scimarkc-${VERSION}-installed || die "Failed to create directory"
unzip $SHELLPACK_SOURCES/$ZIPFILE || die "Failed to extract archive"
export CFLAGS=-O2
make || die "Failed to build scimark ${VERSION}"

exit $SHELLPACK_SUCCESS
#### Description scimarkc
#### Details scimarkc 2
