#!/bin/sh -e

if [ -f CMakeLists.txt ]; then
	mkdir -p build
	cd build
fi

if ! [ -f CMakeCache.txt ]; then
	cmake -DCMAKE_BUILD_TYPE=Release -DUNITY_BUILDS=ON -DWHOLE_PROGRAM_OPTIMISATION=OFF -DBUILD_CLIENT=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
	cp -v compile_commands.json ../
fi

make -j$(nproc)
