#!/bin/sh
if ! [ -f target/release/indivisible ]
then
	echo "ERROR: you have to compile a release build of indivisible first."
	echo "Please run 'cargo build --release'"
	exit 1
fi

PREFIX="${PREFIX:-/usr/local}"

echo "Installing ./target/release/indivisible to $PREFIX/bin/"
install -Dm755 ./target/release/indivisible "$PREFIX/bin/indivisible"
gzip -k indivisible.1
echo "Installing manpage to $PREFIX/share/man/man1/"
install -Dm644 ./indivisible.1.gz "$PREFIX/share/man/man1/indivisible.1.gz"
# clean up compressed file
rm indivisible.1.gz
