#! /bin/sh

OPTS=' '
PGSQL='OFF'
MYSQL='OFF'
GRAPH='OFF'

getarg () {
    if [ "$1" = "MYSQL" ];
    then
        MYSQL='ON'
        OPTS="$OPTS/p:mysql=on "
    fi
    if [ "$1" = "PGSQL" ];
    then
        PGSQL='ON'
        OPTS="$OPTS/p:pgsql=on "
    fi
    if [ "$1" = "GRAPH" ];
    then
        GRAPH='NPLOT'
        OPTS="$OPTS/p:graph=nplot "
    fi
}

if [ -n "$1" ]; then
    getarg "$1"
fi

if [ -n "$2" ]; then
    getarg "$2"
fi

if [ -n "$3" ]; then
    getarg "$3"
fi

(
echo	'all: server'
echo
echo	'debug:'
echo	'	xbuild Ntp.Analyzer.sln /p:Configuration=Debug'
echo
echo	'release:'
echo	'	xbuild Ntp.Analyzer.sln /p:Configuration=Release'
echo
echo	'server:'
echo	"	xbuild /p:Configuration=Server$OPTS Ntp.Analyzer.sln"
echo
echo	'install:'
echo	'	install -d ${DESTDIR}$(PREFIX)/sbin'
echo	'	install script/ntpa ${DESTDIR}$(PREFIX)/sbin'
echo	'	install script/ntpac ${DESTDIR}$(PREFIX)/sbin'
echo	'	install script/ntpav ${DESTDIR}$(PREFIX)/sbin'
echo	'	install -d ${DESTDIR}$(PREFIX)/libexec/ntpa'
echo	'	install bin/NPlot.dll ${DESTDIR}$(PREFIX)/libexec/ntpa'
echo	'	install bin/Ntp.Analyzer.Cli.exe ${DESTDIR}$(PREFIX)/libexec/ntpa'
echo	'	install bin/Ntp.Analyzer.Data.dll ${DESTDIR}$(PREFIX)/libexec/ntpa'
echo	'	install bin/Ntp.Analyzer.dll ${DESTDIR}$(PREFIX)/libexec/ntpa'
echo	'	install bin/Ntp.Analyzer.Import.dll ${DESTDIR}$(PREFIX)/libexec/ntpa'
echo	'	install bin/Ntp.Analyzer.Localize.dll ${DESTDIR}$(PREFIX)/libexec/ntpa'
echo	'	install bin/Ntp.Analyzer.Log.dll ${DESTDIR}$(PREFIX)/libexec/ntpa'
echo	'	install bin/Ntp.Analyzer.Objects.dll ${DESTDIR}$(PREFIX)/libexec/ntpa'
echo	'	install bin/Ntp.Analyzer.Process.dll ${DESTDIR}$(PREFIX)/libexec/ntpa'
echo	'	install bin/Ntp.Analyzer.Validate.Cli.exe ${DESTDIR}$(PREFIX)/libexec/ntpa'
echo	'	install bin/Ntp.Common.dll ${DESTDIR}$(PREFIX)/libexec/ntpa'
echo	'	install bin/Ntp.Config.dll ${DESTDIR}$(PREFIX)/libexec/ntpa'
echo	'	install bin/Ntp.Data.dll ${DESTDIR}$(PREFIX)/libexec/ntpa'
echo	'	install bin/Ntp.Data.Provider.dll ${DESTDIR}$(PREFIX)/libexec/ntpa'
echo	'	install bin/Ntp.Interop.dll ${DESTDIR}$(PREFIX)/libexec/ntpa'
echo	'	install bin/Ntp.Monitor.Client.dll ${DESTDIR}$(PREFIX)/libexec/ntpa'
echo	'	install bin/Ntp.Monitor.Cli.exe ${DESTDIR}$(PREFIX)/libexec/ntpa'
echo	'	install bin/Ntp.Monitor.Server.dll ${DESTDIR}$(PREFIX)/libexec/ntpa'
echo	'	install bin/Ntp.Process.dll ${DESTDIR}$(PREFIX)/libexec/ntpa'

if [ $MYSQL = "ON" ]; then
echo	'	install bin/MySql.Data.dll ${DESTDIR}$(PREFIX)/libexec/ntpa'
fi

if [ $PGSQL = "ON" ]; then
echo	'	install bin/Npgsql.dll ${DESTDIR}$(PREFIX)/libexec/ntpa'
echo	'	install -d ${DESTDIR}$(PREFIX)/libexec/ntpa/de'
echo	'	install -d ${DESTDIR}$(PREFIX)/libexec/ntpa/es'
echo	'	install -d ${DESTDIR}$(PREFIX)/libexec/ntpa/fi'
echo	'	install -d ${DESTDIR}$(PREFIX)/libexec/ntpa/fr'
echo	'	install -d ${DESTDIR}$(PREFIX)/libexec/ntpa/ja'
echo	'	install -d ${DESTDIR}$(PREFIX)/libexec/ntpa/zh-CN'
echo	'	install bin/de/Npgsql.resources.dll ${DESTDIR}$(PREFIX)/libexec/ntpa/de'
echo	'	install bin/es/Npgsql.resources.dll ${DESTDIR}$(PREFIX)/libexec/ntpa/es'
echo	'	install bin/fi/Npgsql.resources.dll ${DESTDIR}$(PREFIX)/libexec/ntpa/fi'
echo	'	install bin/fr/Npgsql.resources.dll ${DESTDIR}$(PREFIX)/libexec/ntpa/fr'
echo	'	install bin/ja/Npgsql.resources.dll ${DESTDIR}$(PREFIX)/libexec/ntpa/ja'
echo	'	install bin/ja/Npgsql.resources.dll ${DESTDIR}$(PREFIX)/libexec/ntpa/zh-CN'
fi

echo	'	install -d ${DESTDIR}$(PREFIX)/etc/ntpa/'
echo	'	install examples/ntpa.conf ${DESTDIR}$(PREFIX)/etc/ntpa/ntpa.conf.sample'
echo
echo	'clean:'
echo	'	xbuild Ntp.Analyzer.sln /p:Configuration=Debug /t:clean'
echo	'	xbuild Ntp.Analyzer.sln /p:Configuration=Release /t:clean'
echo	'	xbuild Ntp.Analyzer.sln /p:Configuration=Server /t:clean'
) > Makefile
