@echo off

set S86=N

if not x%1 == x goto ok

echo Usage: txboot [-s86] file
goto end

:ok

if not x%1 == x-s86 goto nots86
set S86=Y
shift
:nots86

if exist %1.t goto ok2

echo tc: cannot open: %1.t
goto end

:ok2

..\compiler\txtrn < %1.t >%1.UOP
..\compiler\txopt < %1.UOP >%1.tco
del %1.UOP

..\native\txcgboot <%1.tco >%1.s
del %1.tco

if %S86%==Y goto uses86

tasm /t /ml %1.s
del %1.s
tlink %1.obj,%1.exe,nul,..\native\libtx.lib
del %1.obj

goto end

:uses86
..\s86kit\s86b <%1.s >%1.o
del %1.s
echo -o %1.x >__ldctrl
echo %1.o >>__ldctrl
echo ../build/libtx86.o >>__ldctrl
..\s86kit\sld <__ldctrl
del %1.o
del __ldctrl
..\s86kit\cvexe <%1.x >%1.exe
del %1.x

:end
set S86=
