#!/bin/sh

mingwb="i586-mingw32msvc"
if [ ! -f "sevnz.dll" ] || [ ! -f "sevnz.exe" ]
then
svloc=$(wget "http://7-zip.org/" -O - | grep --ignore-case "a href=\"http://downloads.sourceforge.net/sevenzip/" | grep -v ".msi" | grep -v "x64" | head --lines 1 | tr "<" "\n" | tr ">" "\n" | tr "\"" "\n" | grep "http://downloads.sourceforge.net/sevenzip/")
wget "$svloc" -O sevenzip.exe
7z e sevenzip.exe 7z.exe 7z.dll
mv 7z.exe sevnz.exe
mv 7z.dll sevnz.dll
fi
rvern="$(bzr version-info | grep revno | sed 's/revno: //')"
make clean
rm Makefile*
rm release/*
lupdate unetbootin.pro
lrelease unetbootin.pro
./qmake-windows
make
$mingwb-strip --strip-all release/unetbootin.exe
mv release/unetbootin.exe release/unetbootin-windows-$rvern.exe
./upx --lzma release/unetbootin-windows-$rvern.exe
./qmake-linux
make
$mingwb-strip --strip-all unetbootin
mv unetbootin release/unetbootin-linux-$rvern
./upx --lzma release/unetbootin-linux-$rvern

