#!/usr/bin/env bash
set -euo pipefail

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"

# Defaults suitable for automation
: "${CLEAN:=1}"
: "${PREFIX:=/usr/local/imap}"
: "${DEPS_AUTO:=1}"

# Install deps first (Debian/Ubuntu)
./scripts/deps-debian.sh

./scripts/apply-patches.sh
CLEAN="$CLEAN" ./scripts/build.sh
PREFIX="$PREFIX" ./scripts/install.sh
