#!/bin/bash

function die() {
    echo "fatal: $*" >&2
    exit 1
}

function run() {
    echo "\$ $*" >&2
    "$@" || die "failed: $*"
}

run g++ -O2 -fPIC -Wall -Wextra -o solution.o -c -x c++ -std=c++14 solution.cpp
run g++ -O2 -fPIC -Wall -Wextra -o message.o -c -x c++ -std=c++14 message.cpp
run g++ -O2 -fPIC -Wall -Wextra -o solution.so -shared solution.o message.o

