#!/bin/bash
# Sets up openalpr.

# Stop on errors
set -e

PACKAGES=(
  # homeassistant.components.image_processing.openalpr_local
  libopencv-dev libtesseract-dev libleptonica-dev liblog4cplus-dev
)

apt-get install -y --no-install-recommends ${PACKAGES[@]}

# Clone the latest code from GitHub
git clone https://github.com/openalpr/openalpr.git /usr/local/src/openalpr

# Setup the build directory
cd /usr/local/src/openalpr/src
mkdir -p build
cd build

# Setup the compile environment
cmake -DWITH_TEST=FALSE -DWITH_BINDING_JAVA=FALSE --DWITH_BINDING_PYTHON=FALSE --DWITH_BINDING_GO=FALSE -DWITH_DAEMON=FALSE -DCMAKE_INSTALL_PREFIX:PATH=/usr/local ..

# compile the library
make

# Install the binaries/libraries to your local system (prefix is /usr/local)
make install