#!/bin/bash
###SHELLPACK preamble microtput-install 0
WEB_LOCATION=$MICROTPUT_LOCATION
MICROTPUT_BASENAME=`basename $WEB_LOCATION`
MIRROR_LOCATION="$WEBROOT/microtput/`basename $MICROTPUT_BASENAME`"

###SHELLPACK parseargBegin
###SHELLPACK parseargEnd

cd $SHELLPACK_SOURCES || die Sources directory does not exist
rm -rf microtput-${VERSION}-installed
mkdir -p microtput-${VERSION}-installed

sources_fetch $WEB_LOCATION $MIRROR_LOCATION $SHELLPACK_SOURCES/microtput-${VERSION}-installed/$MICROTPUT_BASENAME
###SHELLPACK build_start microtput-${VERSION}-installed
case $MICROTPUT_BUILD in
gcc)
	gcc -O2 -pthread --std=c99 -D_GNU_SOURCE -pthread $MICROTPUT_BASENAME -o microtput
	if [ $? -ne 0 ]; then
		die Failed to build $MICROTPUT_BASENAME
	fi
	;;
none)
	mv $MICROTPUT_BASENAME microtput
	;;
*)
	die Unrecognised build method \"$MICROTPUT_BUILD\"
	;;
esac
	
exit $SHELLPACK_SUCCESS
