#!/bin/sh
if [ ! `id -u` = "0" ]; then
   echo "This script need root access."
   exit 1
fi
case "$1" in
  -i) mkdir build && cd build
      if [ $? -eq 0 ]; then
	cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=release -DCMAKE_CXX_FLAGS_RELEASE="-O2 -march=native" .. && make -j5 install/strip
	cd .. && rm -rf build
      fi ;;
  -u) mkdir build && cd build
      if [ $? -eq 0 ]; then
	cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=release .. && make -j5 install
	make uninstall
        cd .. && rm -rf build
      fi ;;
   *) echo "install <-i> or <-u>"
      echo "-i: Complie and install the program."
      echo "-u: Uninstall program"
esac
