#!/bin/sh

APPNAME=xfpanel-switch
VERSION=1.0

PYTHON=python3

help () {
    echo "Supported options are:"
    echo "    --help                          print this help and exit"
    echo "    --prefix=<path>                 specify installation prefix"
    echo "        <path>/bin - will hold all executables"
    echo "        default <path> is /usr/local"
    echo "    --python=<python executable>    specify python version"
    echo "        python or python3"
    echo "        default <python executable> is $PYTHON"
}

PREFIX="/usr/local"
while [ $# -gt 0 ]; do
    case $1 in
        --help)
            help
            exit 0
            ;;
        --prefix=*)
            PREFIX=`echo $1 | sed 's/--prefix=//'`
            ;;
        --python=*)
            PYTHON=`echo $1 | sed 's/--python=//'`
            ;;
        *)
            echo "Unknown option $1"
            help
            exit 1
            ;;
    esac
    shift
done

echo "Creating Makefile..."
sed -e s,@prefix@,$PREFIX, Makefile.in.in > Makefile.in
sed -e s,@python@,$PYTHON, Makefile.in > Makefile
echo "Installation prefix is $PREFIX"
