#!/bin/bash
echo "Cgminer BlockErupter Win32 builder:"
echo ""
export folder=$(pwd)
cd ~
if ! [ -d cgminer-blockerupter ]
then
git clone https://github.com/wareck/cgminer-gekko.git cgminer-blockerupter
fi
cd cgminer-blockerupter
autoreconf -fi
CFLAGS="-O2 -msse2 -fcommon " ./configure --host=i686-w64-mingw32.static --disable-shared --enable-blockerupter
make
strip cgminer.exe
if [ -d /tmp/cgminer-blockerupter ]; then rm -r -f /tmp/cgminer-blockerupter ;fi
mkdir /tmp/cgminer-blockerupter
cp cgminer.exe /tmp/cgminer-blockerupter
cp $folder/packages/blockerupter/manual.pdf /tmp/cgminer-blockerupter/
cp $folder/packages/blockerupter/start.bat /tmp/cgminer-blockerupter/
cp $folder/packages/blockerupter/zadig-2.7.exe /tmp/cgminer-blockerupter/
cp $folder/packages/blockerupter/cgminer.conf /tmp/cgminer-blockerupter/
cd /tmp/
version=`git ls-remote -h https://github.com/wareck/cgminer-gekko.git | awk '{print $1}' |cut -c1-7`
7z a -tzip cgminer-blockerupter-$version.zip cgminer-blockerupter
lftp -u wareck,zorn692611 ftpperso.free.fr <<EOF
put cgminer-blockerupter-$version.zip -o /crypto/cgminer/cgminer-blockerupter-$version.zip
EOF
if ! [ -d /home/$USER/Bureau/win32_build/ ]; then mkdir /home/$USER/Bureau/win32_build ;fi

cp cgminer-blockerupter-$version.zip /home/$USER/Bureau/win32_build
