@echo off
%slim_home%\slim2c %1 %slim_home%\slim.r\
if errorlevel 1 goto errors
if not exist %1.lnk goto elif
  %slim_home%\linker %1 win32 <%1.lnk >>%1.c
:elif
if not exist %1.lkr goto fi
  %slim_home%\linker %1 win32 <%1.lkr >>%1.c
:fi
if "%2" == "d" goto debug
if "%2" == "o" goto optimize
%CC% -w -c -I%slim_home%\slim.r %1.c
goto link
:optimize
%CC% -O2 -w -c -I%slim_home%\slim.r %1.c
goto link
:debug
%CC% -Zi -w -c -I%slim_home%\slim.r %1.c
:link
if not exist %1.lnk goto fi2
 if "%2" == "d" goto debug2
  %CC% @%1.rsp %slim_home%\slim.r\slim.lib -o %1.exe /nologo /link /nodefaultlib:libcd /defaultlib:odbc32 /defaultlib:wsock32
  goto fi2
:debug2
  %CC% @%1.rsp %slim_home%\slim.r\slimbug.lib -o %1.exe /nologo /link /nodefaultlib:libcd /defaultlib:odbc32 /defaultlib:wsock32 /PDB:vc50.pdb /DEBUG 
:fi2
if "%2" == "" goto else3
  echo Keeping the c
goto fi3
:else3
  del %1.c
:fi3
goto finish
:errors
  echo Errors, compile failed
:finish


