@echo off
SET PASCAL=c:\FPC\2.4.4\sbin\i386-win32\
SET QTDIR=c:\QtSDK\Desktop\Qt\4.7.4\mingw\bin
SET PATH=%PATH%;%PASCAL%

REM SETUP
cd ..
if not exist bin mkdir bin
cd bin

echo Copying the DLLs
xcopy /d/y ..\misc\winutils\bin\* .
xcopy /d/y %QTDIR%\QtCore4.dll .
xcopy /d/y %QTDIR%\QtGui4.dll .
xcopy /d/y %QTDIR%\QtNetwork4.dll .
xcopy /d/y %QTDIR%\libgcc_s_dw2-1.dll .
xcopy /d/y %QTDIR%\mingwm10.dll .

call %QTDIR%\qtenv2.bat
echo Running cmake
cmake -G "MinGW Makefiles" -DCMAKE_INCLUDE_PATH="%CD%\..\misc\winutils\include" -DCMAKE_LIBRARY_PATH="%CD%\..\misc\winutils\lib" ..

echo Running make
mingw32-make -lSDL -lSDL_Mixer install

echo Creating shortcut...
if /i "%PROGRAMFILES(X86)%"=="" (
COPY ..\misc\winutils\Hedgewars_x86.lnk "%HOMEPATH%\Desktop\Hedgewars.lnk" 
) else (
COPY ..\misc\winutils\Hedgewars_x64.lnk "%HOMEPATH%\Desktop\Hedgewars.lnk"
)

echo ALL DONE, hedgewars has been successfully compiled and installed
echo A shortcut on the desktop was created
pause