@echo off
rem
rem Note the gcc lines may exceed the normal line length
rem in Brief - watch out for those lines being truncated
rem
set _dbg=
set _prg=%1
set _opt=%2
set _asm=1

if exist "%_prg%.cpp" goto ok
if exist "%_opt%.cpp" goto swap

echo.
echo Usage:
echo   ccs cppfile [options]
echo.
echo Current options are -d for debug
echo.
goto end

:swap
set _opt=%1
set _prg=%2

:ok

if "%_opt%"=="-d" set _dbg=1
if "%_opt%"=="-D" set _dbg=1

if exist %_prg%.lis del %_prg%.lis
if exist %_prg%.s del %_prg%.s

if "%_dbg%"=="1" goto debug
echo.
echo Compiling %_prg% without debug info
gcc -S -Wall -Wno-ctor-dtor-privacy -mcpu=arm710 -mapcs-32 -mshort-load-bytes -msoft-float -I. -I- -I..\inc -I..\..\Epoc32\Include -D__GCC32__ -D__DLL__ -D__MARM__ -D__EPOC32__ -O -fomit-frame-pointer -fvtable-thunks -fcheck-new %_prg%.cpp 2>%_prg%.lis
goto done
:debug
echo.
echo Compiling %_prg% with debug info
gcc -S -Wall -Wno-ctor-dtor-privacy -mcpu=arm710 -mapcs-32 -mshort-load-bytes -msoft-float -I. -I- -I..\inc -I..\..\Epoc32\Include -D__GCC32__ -D__DLL__ -D__MARM__ -D__EPOC32__ -D_DEBUG -O -fvtable-thunks -fcheck-new %_prg%.cpp 2>%_prg%.lis
:done
if NOT EXIST %_prg%.S goto xtype
unix2dos %_prg%.s %_prg%.ss
del %_prg%.s
if not "%_asm%"=="1" goto noasm
echo Adding addresses...
as -aln %_prg%.ss >%_prg%.s
erase a.out
goto doneasm
:noasm
copy %_prg%.ss %_prg%.s >NUL
:doneasm
echo.
del %_prg%.ss
:xtype
if NOT EXIST %_prg%.LIS goto ytype
unix2dos %_prg%.lis %_prg%.lst
del %_prg%.lis
ren %_prg%.lst %_prg%.lis
:ytype
TYPE %_prg%.LIS
:end
set _dbg=
set _prg=
set _opt=

