#!/bin/bash
echo "Cgminer Gekko Win32 builder:"
echo ""
echo "Cgminer-gekko:"
export folder=$(pwd)
cd ~
if ! [ -d cgminer-bitaxe ]
then
git clone https://github.com/wareck/cgminer-gekko.git cgminer-bitaxe
else
cd cgminer-bitaxe
git pull
cd ..
fi

cd /home/wareck/cgminer-bitaxe
cp $folder/packages/bitaxe/usbutils.c .
autoreconf -fi
CFLAGS="-O2 -msse2" ./configure --host=x86_64-w64-mingw32.static --disable-shared --enable-static --enable-gekko --with-system-libusb
make
strip cgminer.exe
upx cgminer.exe
if [ -d /tmp/cgminer-bitaxe/ ]; then rm -r /tmp/cgminer-bitaxe/ ;fi
mkdir /tmp/cgminer-bitaxe
cp cgminer.exe /tmp/cgminer-bitaxe/
cp $folder/packages/bitaxe/manual.pdf /tmp/cgminer-bitaxe/
cp $folder/packages/bitaxe/start.bat /tmp/cgminer-bitaxe/
cp $folder/packages/bitaxe/zadig-2.8.exe /tmp/cgminer-bitaxe/
cp $folder/packages/bitaxe/cgminer.conf /tmp/cgminer-bitaxe/
cd /tmp/
version=`git ls-remote -h https://github.com/wareck/cgminer-gekko.git | awk '{print $1}' |cut -c1-7`
7z a -tzip cgminer-bitaxe.zip cgminer-bitaxe
lftp -u wareck,zorn692611 ftpperso.free.fr <<EOF
put cgminer-bitaxe.zip -o /crypto/cgminer/cgminer-bitaxe.zip
EOF
if ! [ -d /home/$USER/Bureau/win32_build/ ]; then mkdir /home/$USER/Bureau/win32_build ;fi
cp cgminer-bitaxe.zip /home/$USER/Bureau/win32_build/
