#!/bin/bash

set -euo pipefail

MDQ_HOME=${PWD%/*/*}

transmission_version=${1:-4}

cd transmission-all

./GET-AND-COMPILE-OPENSSL.sh

./GET-AND-COMPILE-CURL.sh

if [ $transmission_version = 4 ] ; then
    # Requires cmake
    command -v cmake

    if [ $? = 0 ] ; then
	./GET-AND-COMPILE-TRANSMISSION4.sh
    else
	echo "----"
	echo "Compiling transmission v4.x from source requires 'cmake'"
	echo "This can be installed using:"
	echo "  ./GET-SELFCONTAINED-CMAKE.sh"
	echo "Then running its prepare script and sourcing its setup file"
	echo "----"
	exit 1
    fi
else
    # Expects libevent-dev, intltool to be installed (e.g., via apt install)
    ./GET-AND-COMPILE-TRANSMISSION3.sh
fi
cd ..
