#!/bin/bash
#
# Copyright (C) 2018 Purism SPC
#
# SPDX-License-Identifier: GPL-3.0+
#
# prerequisites 'libusb-1.0-0-dev libzip-dev'

usage() {
  echo "Usage : $1 "
  echo "    -i install uuu as well"
}

cwd=$(pwd)

install_uuu=0

while getopts "hi" opt; do
  case ${opt} in
    i)
      install_uuu=1
      ;;
    \?)
      echo "Invalid Option: -$OPTARG" 1>&2
      usage "$0"
      exit 0
      ;;
    h )
      usage "$0"
      exit 0
      ;;
  esac
done

CWD=`pwd`

mkdir -p build 
cd build
git clone https://source.puri.sm/Librem5/mfgtools

cd mfgtools
cmake ./

make

if [ "${install_uuu}" == 1 ]; then
    sudo make install
fi

