@echo off

set __MODEL=%1
if x%__MODEL% == x set __MODEL=%MODEL%
if x%__MODEL% == x set __MODEL=s

set __LNG=%2
if x%__LNG% == x set __LNG=%LNG%
if x%__LNG% == x set __LNG=english

set __MCDIR=
if not x%MCDIR% == x set __MCDIR=%MCDIR%\

set FDINC=%FREEDOS%\SRC\INCLUDE
set FDBIN=%FREEDOS%\SRC\BIN
set SUPPL=%FREEDOS%\SRC\LIB\MC\suppl_s.lib
set MSGLIB=%FREEDOS%\SRC\LIB\MC\s_%__LNG%.lib

rm -sfr *.obj msg.lib yerror.h__ comp.rsp lib.rsp
%FDBIN%\MsgComp %FDINC%\%LNG% %LNG% comp.rsp lib.rsp yerror.h
if errorlevel 1 goto msgcomperr
if not exist foreach.com cc.com foreach.c -fop _MICROC_=1
if errorlevel 1 goto ende
ForEach comp.rsp cc.com %% -pl _MICROC_=1
if errorlevel 1 goto ende
lib.exe /scw msg @lib.rsp, msg
rm /frsl=1 1comp.rsp 1lib.rsp comp.rsp lib.rsp Makefile.msg


ForEach bc_compil.ccc cc.com %% -flop _MICROC_=1 NDEBUG=1
if errorlevel 1 goto ende
echo %SUPPL% msg.lib %MSGLIB% %__MCDIR%mclib >mc-lib.inc
val /NCI %__MCDIR%pc86rl_s *.obj,LLIB,NUL,@mc-lib.inc;
rm -sfr *.obj msg.lib yerror.h__ comp.rsp lib.rsp mc-lib.inc
goto ende

msgcomperr:
if exist yerror.h__ rm -sfr yerror.h
if exist yerror.h__ ren yerror.h__ yerror.h >nul

:ende
set __MODEL=
set __LNG=
set __MCDIR=
set SUPPL=
set MSGLIB=
set FDINC=
set FDBIN=
