#!/bin/sh
# Executable wrapper script
# Ensures the program is up-to-date, then hands over

set -e
cd "$(dirname "$0")"
PROGRAM_NAME="$(basename "$0")"

# Create build directory
[ -d build ] || mkdir build

# Generate build files
[ -f build/CMakeCache.txt ] || ./bootstrap

# Generate binaries
# Users of GNU Make can enable parallel builds on N cores by setting
# MAKEFLAGS=-jN when calling this script.
cmake --build build

# Run main binary
exec build/$PROGRAM_NAME "$@"
