@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

if x%__MODEL% == mt goto tinyModel

set ERRLIST=
if exist errlist set ERRLIST=Yes

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

call mkdynsrc.bat

if exist foreach.com goto haveFE
cc foreach.xc -fop _MICROC_=1 NDEBUG=1
if errorlevel 1 goto ende
if not exist foreach.com goto err1
:haveFE

type compile.ccc >compile.tmp
type dyn_src >>compile.tmp
if x%errlist% == x .\foreach compile.tmp WCC.EXE -m%__MODEL% %%name: @conf.occ
if not x%errlist% == x .\foreach compile.tmp WCC.EXE -m%__MODEL% -fr=%%fname:.err %%name: @conf.occ
if not x%errlist% == x for %%a in (*.err) do type %%a >>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 *.err compile.tmp
goto ende

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

:tinyModel
echo Watcom C doesn't require special TINY object files, just
echo create a SMALL memory model library.
goto ende

:err1
echo Failed to make FOREACH.COM (from FOREACH.XC)
echo To compile FOREACH you need Micro-C.
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=
