2016-05-19 14:23:20 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
function msg_err {
|
|
|
|
printf "\033[41;30m err \033[0m %s\n" "$@"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function msg {
|
|
|
|
printf "\033[36;1m info \033[0m%s\n" "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
function main
|
|
|
|
{
|
|
|
|
[[ -d ./build ]] && msg_err "A build directory already exists"
|
|
|
|
[[ -d ./.git ]] && {
|
|
|
|
git submodule update --init --recursive || msg_err "Failed to clone submodules"
|
|
|
|
}
|
|
|
|
|
|
|
|
mkdir ./build || msg_err "Failed to create build dir"
|
|
|
|
cd ./build || msg_err "Failed to enter build dir"
|
|
|
|
|
2016-05-19 22:35:09 -04:00
|
|
|
cmake -DCMAKE_INSTALL_PREFIX=/usr .. || \
|
2016-05-19 14:23:20 -04:00
|
|
|
msg_err "Failed to generate build... read output to get a hint of what went wrong"
|
|
|
|
|
|
|
|
make || msg_err "Failed to build project"
|
|
|
|
|
|
|
|
echo -e "\n"
|
|
|
|
|
|
|
|
read -N1 -p "Do you want to execute \"sudo make install\"? [Y/n] " -r choice
|
2016-05-23 22:44:02 -04:00
|
|
|
echo
|
2016-05-19 14:23:20 -04:00
|
|
|
|
|
|
|
if [[ "${choice^^}" == "Y" ]]; then
|
|
|
|
sudo make install || msg_err "Failed to install executables..."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|