@echo off

rem    options:
rem  -DDEBUG -DDEBUG_MEMORY -DDEBUG_TIME
rem  -DL7e

set armdir=..
set sdkdir=..\SDK
set lib_o=..\Lib.o

set src_input=src\Backuper.c
set tmp_o=Backuper.o
set elfname=Backuper

rem NORMAL
set output=bin\%elfname%.elf

if exist %output% del %output%
if exist bin goto :nbin
md bin
:nbin
%armdir%\tcc -O2  -I%sdkdir% -c -bigend -apcs  /interwork %options% %src_input%
%armdir%\armlink -nolocals -reloc -first Lib.o(Lib) -o %output% %tmp_o% %ext_o% %lib_o%

rem DEBUG
set output=bin\debug\%elfname%.elf
set ext_o=../dbg/dbg.o
set options=-DDEBUG

if exist %output% del %output%
if exist bin\debug goto :nbindebug
md bin\debug
:nbindebug
%armdir%\tcc -O2  -I%sdkdir% -c -bigend -apcs  /interwork %options% %src_input%
%armdir%\armlink -nolocals -reloc -first Lib.o(Lib) -o %output% %tmp_o% %ext_o% %lib_o%

if exist obj goto :nobj
md obj
:nobj
move /Y *.o obj\

pause