@rem
@rem Batch file to compile an UZIX application under MSDOS using 22NICE
@rem (c) 2001 A&L Software
@rem
@rem This program is under GPL License.
@rem
@rem 22NICE can be found at http://www.simtel.net
@rem

@echo off
if "%1" == "" goto error
if not exist %1.c goto nofile
echo.
echo Compiling %1.c for UZIX
echo.
echo Preprocessing...
cpp -DMSX_UZIX_TARGET -DHI_TECH_C -Dz80 -I %1.c $C1.T
echo Pass 1...
p1 $C1.T $C2.T $C3.T
echo Generating C code...
cgen $C2.T $C1.T
if "%2" == "-o" goto optim
echo Generating assembly code...
zas -N -o%1.O $C1.T

:compile
if exist $c1.t del $c1.t > nul
if exist $c2.t del $c2.t > nul
if exist $c3.t del $c3.t > nul
echo Linking...
link -Z -M$$.m -Ptext=0,data,bss -C100H -O%1 C0U.O %1.O %2 %3 %4 %5 %6 %7 %8 %9 LIBC.LIB
del %1.O > nul
if exist %1.map del %1.map > nul
if exist $$.m ren $$.m %1.map > nul
if exist $$.m del $$.m
echo Done.
goto end

:optim
echo Optimizing...
optim $C1.T $C2.T
echo Generating assembly code...
zas -J -N -o%1.O $C2.T
goto compile

:nofile
echo Source file does not exist.
goto end

:error
echo usage: ucc sourcefile [-o] [library1] [library2...]
echo        source filename must be supplied without extension.
echo        option -o disables code optimization.
echo        library1, library2, etc are other libraries to link
echo        map file is automatically generated (sourcefile.map)

:end
