@echo off
SET THEFILE=pencil.exe
echo Linking %THEFILE%
C:\lazarus\fpc\3.0.2\bin\i386-win32\ld.exe -b pei-i386 -m i386pe  --gc-sections  -s --subsystem windows --entry=_WinMainCRTStartup   --base-file base.$$$ -o pencil.exe link.res
if errorlevel 1 goto linkend
C:\lazarus\fpc\3.0.2\bin\i386-win32\dlltool.exe -S C:\lazarus\fpc\3.0.2\bin\i386-win32\as.exe -D pencil.exe -e exp.$$$ --base-file base.$$$ 
if errorlevel 1 goto linkend
C:\lazarus\fpc\3.0.2\bin\i386-win32\ld.exe -b pei-i386 -m i386pe  -s --subsystem windows --entry=_WinMainCRTStartup  -o pencil.exe link.res exp.$$$
if errorlevel 1 goto linkend
C:\lazarus\fpc\3.0.2\bin\i386-win32\postw32.exe --subsystem gui --input pencil.exe --stack 256000
if errorlevel 1 goto linkend
goto end
:asmend
echo An error occured while assembling %THEFILE%
goto end
:linkend
echo An error occured while linking %THEFILE%
:end
