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

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


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



echo "Cgminer-all-usb:"
cd /home/wareck/cgminer-gekko
CFLAGS="-O2 -msse2" ./configure --host=x86_64-w64-mingw32.static --enable-static --disable-shared --enable-extranonce --enable-gekko --enable-bflsc  \
--enable-bitforce --enable-bitfury --enable-cointerra --enable-drillbit --enable-hashfast --enable-hashratio --enable-icarus  --enable-klondike  --enable-modminer \
--enable-extranonce --with-system-libusb
make
strip cgminer.exe
upx cgminer.exe
if [ -d /tmp/cgminer-gekko ]; then rm -r -f /tmp/cgminer-gekko ;fi
if [ -d /tmp/cgminer-gekko-all-usb ]; then rm -r -f /tmp/cgminer-gekko-all-usb ;fi
mkdir /tmp/cgminer-gekko-all-usb
cp cgminer.exe /tmp/cgminer-gekko-all-usb
cp $folder/packages/gekko/manual.pdf /tmp/cgminer-gekko-all-usb/
cp $folder/packages/gekko/start.bat /tmp/cgminer-gekko-all-usb/
cp $folder/packages/gekko/zadig-2.8.exe /tmp/cgminer-gekko-all-usb/
cp $folder/packages/gekko/cgminer.conf /tmp/cgminer-gekko-all-usb/
cd /tmp/

version=`git ls-remote -h https://github.com/wareck/cgminer-gekko.git | awk '{print $1}' |cut -c1-7`
7z a -tzip cgminer-gekko-all-usb-xnsub-$version.zip cgminer-gekko-all-usb
lftp -u wareck,zorn692611 ftpperso.free.fr <<EOF
put cgminer-gekko-all-usb-xnsub-$version.zip -o /crypto/cgminer/cgminer-gekko-all-usb-xnsub-$version.zip
EOF
if ! [ -d /home/$USER/Bureau/win32_build/ ]; then mkdir /home/$USER/Bureau/win32_build ;fi
cp cgminer-gekko-all-usb-xnsub-$version.zip /home/$USER/Bureau/win32_build/
cd /tmp
rm -r -f /tmp/cgminer-gekko-all-usb

echo "Cgminer-all-usb:"
cd /home/wareck/cgminer-gekko
CFLAGS="-O2 -msse2" ./configure --host=x86_64-w64-mingw32.static --enable-static --disable-shared --enable-extranonce --enable-gekko --enable-bflsc  \
--enable-bitforce --enable-bitfury --enable-cointerra --enable-drillbit --enable-hashfast --enable-hashratio --enable-icarus  --enable-klondike  --enable-modminer \
--disable-extranonce --with-system-libusb
make
strip cgminer.exe
upx cgminer.exe
if [ -d /tmp/cgminer-gekko ]; then rm -r -f /tmp/cgminer-gekko ;fi
if [ -d /tmp/cgminer-gekko-all-usb ]; then rm -r -f /tmp/cgminer-gekko-all-usb ;fi
mkdir /tmp/cgminer-gekko-all-usb
cp cgminer.exe /tmp/cgminer-gekko-all-usb
cp $folder/packages/gekko/manual.pdf /tmp/cgminer-gekko-all-usb/
cp $folder/packages/gekko/start.bat /tmp/cgminer-gekko-all-usb/
cp $folder/packages/gekko/zadig-2.8.exe /tmp/cgminer-gekko-all-usb/
cp $folder/packages/gekko/cgminer.conf /tmp/cgminer-gekko-all-usb/
cd /tmp/

version=`git ls-remote -h https://github.com/wareck/cgminer-gekko.git | awk '{print $1}' |cut -c1-7`
7z a -tzip cgminer-gekko-all-usb-$version.zip cgminer-gekko-all-usb
lftp -u wareck,zorn692611 ftpperso.free.fr <<EOF
put cgminer-gekko-all-usb-$version.zip -o /crypto/cgminer/cgminer-gekko-all-usb-$version.zip
EOF
if ! [ -d /home/$USER/Bureau/win32_build/ ]; then mkdir /home/$USER/Bureau/win32_build ;fi
cp cgminer-gekko-all-usb-$version.zip /home/$USER/Bureau/win32_build/
cd /tmp
rm -r -f /tmp/cgminer-gekko-all-usb
