#!/bin/sh
VERSION=0.2.0
eval `grep VERSION qiph.pro | awk '{print $3}'`
echo $VERSION

WINEBASEDIR=/home/rgareus/.wine/drive_c/x-prefix
NSISEXE=/home/rgareus/.wine/drive_c/Program\ Files/NSIS/makensis.exe
unset CC

qmake -spec win32-x-g++
make || exit

NSIDIR=nsi
mkdir $NSIDIR

cp -v release/qiph.exe $NSIDIR || exit
cp -v misc/fftheofwd.bat $NSIDIR || exit
cp -v win/ffmpeg2theora.exe $NSIDIR || exit
cp -v win/oggfwd.exe $NSIDIR || exit

QTBIN=/home/rgareus/.wine/drive_c/Qt/2010.04/qt/bin
cp -v $QTBIN/QtGui4.dll $NSIDIR
cp -v $QTBIN/QtCore4.dll $NSIDIR
cp -v $QTBIN/libgcc_s_dw2-1.dll $NSIDIR
cp -v $QTBIN/mingwm10.dll $NSIDIR

cat misc/qiph.nsi.tpl | sed 's/VERSION/'$VERSION'/' > $NSIDIR/qiph.nsi
wine "$NSISEXE" $NSIDIR/qiph.nsi || exit


make clean
rm -rf release
rm -f Makefile.Debug Makefile.Release Makefile

echo -n "UPLOAD? [enter|CTRL-C]" ; read
rsync -P $NSIDIR/qiph_installer_v$VERSION.exe  rg42.org:/var/sites/inout/docroot/software/
