#!/bin/bash

set -euo pipefail

MDQ_HOME=${PWD%/*/*/*}


if [ ! -f transmission-3.00.tar.xz ] ; then
   wget https://raw.githubusercontent.com/transmission/transmission-releases/master/transmission-3.00.tar.xz
fi

if [ ! -d transmission-3.00 ] ; then
    tar -xvf transmission-3.00.tar.xz
fi

set +u
if [ "x$PKG_CONFIG_PATH" = "x" ] ; then
    export PKG_CONFIG_PATH="$MDQ_HOME/local/lib/pkgconfig:$MDQ_HOME/local/lib64/pkgconfig"
else
    export PKG_CONFIG_PATH="$MDQ_HOME/local/lib/pkgconfig:$MDQ_HOME/local/lib64/pkgconfig:$PKG_CONFIG_PATH"
fi
set -u


cd transmission-3.00

./configure \
    --prefix=$MDQ_HOME/local \
    --enable-cli \
    --enable-daemon \
    --disable-gtk \
    --disable-mac

make

make install

cd ..
