#!/usr/bin/env bash

if [ "$(id -u)" != "0" ]; then
	echo "should execute with sudo. gonna exit";
	exit 1;
fi

which cmake > /dev/null || apt-get install -y cmake
which valgrind > /dev/null || apt-get install -y valgrind
which lcov > /dev/null || apt-get install -y lcov

if [ ! -e /usr/include/libxml2 ]; then
	apt-get install -y libxml2-dev
fi

if [ ! -e /usr/include/zip.h ]; then
	apt-get install -y libzip-dev
fi

which pip > /dev/null || apt-get install -y python-pip
which gcovr > /dev/null || pip install gcovr

if [ ! -e /usr/local/lib/libcheck.so ]; then
	apt-get remove -y check
	rm -rf check-0.9.10
	tar xzf check-0.9.10.tar.gz
	cd check-0.9.10
	./configure
	make
	make install
	cd -
	rm -rf check-0.9.10
fi
