@echo off

set FRAME=none
set S86=

goto begin

:Usage
echo MAKEGEN: Usage: [-s86] {-asm or -hll} type
goto end

:begin

if x%1 == x goto Usage

:moreargs
if not x%1 == x-asm goto noasm
set FRAME=asm
shift
goto moreargs
:noasm
if not x%1 == x-hll goto nohll
set FRAME=hll
shift
goto moreargs
:nohll
if not x%1 == x-s86 goto nos86
set S86=-s86
shift
goto moreargs
:nos86

if x%1 == x goto Usage
if %FRAME% == none goto Usage

set OUTFILE=txcg%1
set DEFFILE=cg%1.def
set FRAMEFILE=txcg_%FRAME%_frame

if exist %DEFFILE% goto defok
	echo MAKEGEN: cannot open definition file: %DEFFILE%
	goto end
:defok

if exist %FRAMEFILE% goto frameok
	echo MAKEGEN: cannot open file file: %FRAMEFILE%
	goto end
:frameok

copy %FRAMEFILE% txcg_frame
.\txcgg <%DEFFILE% >%OUTFILE%.pp
del txcg_frame

..\compiler\txpp <%OUTFILE%.pp >%OUTFILE%.t
del %OUTFILE%.pp

call txboot.bat %S86% %OUTFILE%

:end
set FRAME=
set OUTFILE=
set DEFFILE=
set FRAMEFILE=
set S86=
