#!/bin/bash


# Initial set up...
# cd 
# git clone https://github.com/LinuxCNC/linuxcnc.git linuxcnc-dev
# cd linuxcnc-dev/src
# ./autogen.sh
# ./configure --with-realtime=uspace
# make
# sudo make setuid


# To update....
cd ~/linuxcnc-dev
# git fetch
# git pull
git status -uno
read -t 30 -p "Will start recompile in 30 seconds, CTRL-C to abort"


git fetch; git reset --hard origin/master
cd src
./autogen.sh
./configure --with-realtime=uspace --enable-build-documentation=html  --enable-build-documentation-translation=no
make clean
make
sudo make setuid

read -t 120 -p "Do you want to run the tests (y/N): " response
response=${response:-N}

if [ "$response" = "y" ] || [ "$response" = "Y" ];
then
  # run tests
  cd ~/linuxcnc-dev
  . ./scripts/rip-environment
  runtests
fi