@ECHO OFF
SET ORGPATH=%PATH%
SET GCCBIN=""
SET ENV_WINX64=0

FOR /F "usebackq" %%t IN (`83 "%ProgramFiles%\BestTech\GCC Developer Lite\GCC\x64\bin"`) DO SET GCCBIN=%%t
if not exist %GCCBIN% FOR /F "usebackq" %%t IN (`83 "%ProgramFiles%\BestTech\GCC Developer Lite\GCC\x86\bin"`) DO SET GCCBIN=%%t
if not exist %GCCBIN% FOR /F "usebackq" %%t IN (`83 "%ProgramFiles(x86)%\BestTech\GCC Developer Lite\GCC\x64\bin"`) DO SET GCCBIN=%%t
if not exist %GCCBIN% FOR /F "usebackq" %%t IN (`83 "%ProgramFiles(x86)%\BestTech\GCC Developer Lite\GCC\x86\bin"`) DO SET GCCBIN=%%t
if not exist %GCCBIN% goto END

echo %GCCBIN% | find "x64" >NUL
if not ERRORLEVEL 1 SET ENV_WINX64=1

@SET PATH=%GCCBIN%\..\..\..\msys32;%GCCBIN%;%ORGPATH%

make %1
@IF ERRORLEVEL 1 GOTO FAIL
@GOTO SUCCESS
:FAIL
@ECHO ERROR !!!
@PAUSE
@GOTO END
:SUCCESS
@ECHO SUCCESS !!!
@timeout 2 > nul
:END
@SET PATH=%ORGPATH%
