#!/bin/bash

run () {

    ONELOOPINSTALLD="$1"
    VERSION="$2"
	TARBALLPATH="$3"
	CMAKEPATH="$4"	
    mkdir -p $ONELOOPINSTALLD
    cd $ONELOOPINSTALLD
    echo "Decompressing COLLIER"
    tar xvzf ${TARBALLPATH}
	echo "Enter COLLIER directory and installing COLLIER"
    cd COLLIER-${VERSION}/build
	${CMAKEPATH}/bin/cmake -Dstatic=ON ..
	make
	cd ..
	echo "Copying the static library and modules generated to target directory"
	cp libcollier.a $ONELOOPINSTALLD
	mkdir $ONELOOPINSTALLD/include
	cp modules/*.mod $ONELOOPINSTALLD/include/
    cd ..
    echo "Finished installing COLLIER"
}

run "$@"
