@echo off
if x%1 == xall goto makAll
if x%1 == xALL goto makAll
if x%1 == xAll goto makAll

set __MODEL=%1
if x%__MODEL% == x set __MODEL=%MODEL%
if x%__MODEL% == x goto errM

set ERRLIST=
if exist errlist set ERRLIST=Yes

..\..\bin\rm -sf *.obj errlist compile.tmp

call mkdynsrc.bat

echo Compiling memory model %__MODEL%
type compile.ccc >compile.tmp
type dyn_src >>compile.tmp
if x%ERRLIST% == x BCC.EXE +BccDos.Cfg -m%__MODEL% -DNDEBUG=1 -O2 -O -Ol -Z -Obeimpv -c @compile.tmp
if not x%ERRLIST% == x BCC.EXE +BccDos.Cfg -m%__MODEL% -DNDEBUG=1 -O2 -O -Ol -Z -Obeimpv -c @compile.tmp >errlist
if exist errlist copy errlist errlist._%__MODEL% >nul

if errorlevel 1 goto ende

if exist suppl_%__MODEL%.lib del  suppl_%__MODEL%.lib >nul
..\..\bin\LIB suppl_%__MODEL%.lib /SCW +- .\*.obj , suppl_%__MODEL%.lst
..\..\bin\rm -sf *.obj compile.tmp
goto ende

:makAll
for %%a in (t s m c l h) do call %0 %%a
goto ende

:errM
echo Script to compile the supplemental library with Borland C
echo Useage: %0 memory_model
echo -or- define the environment variable MODEL with the memory_model
echo -or- call	%0 all
echo to create the libraries for all memory models

:ende
set __MODEL=
set ERRLIST=
