#!/bin/bash
set -exuo pipefail

build_command()
{
	./bootstrap
	./configure CFLAGS="-ggdb -O0" \
		    --prefix=/usr \
		    --enable-logging=verbose

	nump=$(grep -c processor /proc/cpuinfo)
	make -j$(( nump / 2 + 1 ))
}

print_logs()
{
	set +e
	echo "Printing meson log"
	cat build/meson-logs/meson-log.txt
}

if ! build_command ; then
	print_logs
	exit 1
fi
