@echo off

rem #
set bin=..\%1%
set name=%2%

if not exist %bin%\%name%.arc exit

rem # Retreive other arguments in one "opts" string :
shift 
shift
set opts= 
set empty=''
:next
set x='%1'
IF %x% EQU %empty% goto end 
set opts=%opts% %1
shift
goto next
:end
set empty=
set x=

if exist %bin%\%name%\%name%_dll.obj goto component

:linker
%CMTROOT%\VisualC\cmt.exe build windefs %bin%\%name%.arc >%bin%\%name%.def

lib.exe /nologo /machine:ix86 /def:%bin%\%name%.def /out:%bin%\%name%.lib

if exist %bin%\%name%.dll del %bin%\%name%.dll

link.exe /nologo /dll /out:%bin%\%name%.dll %bin%\%name%.exp %bin%\%name%.arc %opts%

goto return

:component
link.exe /nologo /dll /out:%bin%\%name%.dll %bin%\%name%\%name%_dll.obj %bin%\%name%.arc /machine:ix86 %opts%

:return
set opts=

