#!/bin/bash
###SHELLPACK preamble parsecbuild-bench 0

###SHELLPACK parseargBegin
###SHELLPACK parseargInstall
###SHELLPACK parseargParam	--parallel	PARSEC_PARALLEL
###SHELLPACK parseargParam	--size		PARSEC_SIZE
###SHELLPACK parseargEnd

###SHELLPACK check_install_required parsecbuild-${VERSION}
source env.sh
case $PARSEC_PARALLEL in
any)
	PACKAGES="blackscholes bodytrack canneal dedup facesim ferret fluidanimate freqmine netdedup netferret netstreamcluster raytrace streamcluster swaptions vips x264 splash2.barnes splash2.cholesky splash2.fft splash2.fmm splash2.lu_cb splash2.lu_ncb splash2.ocean_cp splash2.ocean_ncp splash2.radiosity splash2.radix splash2.raytrace splash2.volrend splash2.water_nsquared splash2.water_spatial splash2x.barnes splash2x.cholesky splash2x.fft splash2x.fmm splash2x.lu_cb splash2x.lu_ncb splash2x.ocean_cp splash2x.ocean_ncp splash2x.radiosity splash2x.radix splash2x.raytrace splash2x.volrend splash2x.water_nsquared splash2x.water_spatial"
	;;
gcc-pthreads)
	PACKAGES="blackscholes bodytrack canneal facesim ferret fluidanimate netdedup netferret netstreamcluster raytrace streamcluster swaptions vips x264"
	;;
*)
	die Unrecognised parallelisation method $PARSEC_PARALLEL
	;;
esac

for PACKAGE in $PACKAGES; do
	unset CXXFLAGS
	if [ "$PACKAGE" = "bodytrack" ]; then
		export CXXFLAGS="-std=c++11"
	fi
	echo Building $PACKAGE
	parsecmgmt -a build -p $PACKAGE -c $PARSEC_PARALLEL || die "Failed to build package $PACKAGE"
done

###SHELLPACK init_complete
echo Parsec successfully built
exit $SHELLPACK_SUCCESS
