@if "%MOTOCODER_DIR%" NEQ "" goto got_motocoder
@setlocal
@set MOTOCODER_DIR=C:\Program Files\Woodward\MotoHawk\MotoCoder
@:got_motocoder


@echo ### Parsing VarDecs


@"%MOTOCODER_DIR%\bin\MotoParser.exe" /DBStructVer=8 /verbosity=7 	/d=.\ControlCoreClassic\API 	/d=.\ControlCoreClassic\API\Framework 	/d=.\ControlCoreClassic\API\FileSystem 	/d=.\ControlCoreClassic\API\MotoTronSpecific 	/d=.\ControlCoreClassic\API\MotoTronProtocol 	/d=. 	/o=.\TDB 	TableDB.tdb

@if ERRORLEVEL 1 exit /B 1

@echo ### Generating MotoTune DLL

@"%MOTOCODER_DIR%\bin\nant\bin\nant.exe" -buildfile:TDB\Database.build -D:required.installdir="C:\Program Files\Woodward\DevelopmentTools\Toolchains\GCC\win32-pe\3_4_5" -D:database.basename=Controlle_027 -q -nologo rebuild
@if ERRORLEVEL 1 exit /B 1

@echo ### Completed MotoTune DLL

@echo ### Compiling and Linking

@"%MOTOCODER_DIR%\bin\nant\bin\nant.exe" -buildfile:Controller_DEV.build -nologo rebuild
@if ERRORLEVEL 1 exit /B 1
@"%MOTOCODER_DIR%\bin\ESTconvert.exe" .\Target\Controller.elf -b -c -g > NUL 2>&1
@"%MOTOCODER_DIR%\bin\MotoConvert.exe" -project=MPC5xx -TransformBetween=0x00400000-0x0041FFFF -TransformBetween=0x00000000-0x0006FFFF -toolchain=GCC -map=.\Target\Controller.map -srec=.\Target\Controller.run -tdbver=1 -tdb=EriRequestTableList -crctable=g_pCRCBlockPtr -InitialisedRAM=.ramcals,.romcals -InitialisedRAM=.data,.romdata -InitialisedRAM=.sdata,.romsdata -out=.\Target\Controller.sr -encrypt=.\Target\Controller_027_DEV.srz
@echo ### Creating Build Statistics
@"%MOTOCODER_DIR%\bin\MotoElfParser.exe" -i ".\Target\Controller.elf" -o ".\Target\Controller_elf.xml"
@if ERRORLEVEL 1 exit /B 1
@"%MOTOCODER_DIR%\bin\Transform.exe" -o ".\Target\Controller_symbols.xml" ".\Target\Controller_elf.xml" "%MOTOCODER_DIR%\Transforms\BuildStats_IntermediateGenerate.xsl" LinkerDefinitionXML="%cd%\LinkerDefinition_DEV.xml"
@if ERRORLEVEL 1 exit /B 1
@"%MOTOCODER_DIR%\bin\Transform.exe" ".\Target\Controller_symbols.xml" "%MOTOCODER_DIR%\Transforms\BuildStats_Print.xsl" BuildStatsSymbolsXML="%cd%\BuildStatsSymbols.xml"
@if ERRORLEVEL 1 exit /B 1



@"C:\Program Files\Woodward\DevelopmentTools\Toolchains\GCC\powerpc-eabi\4_4_0\\bin\nm.exe" -f sysv .\Target\Controller.elf > .\Target\Controller.sym 

@echo ### Installing .srz in C:\ECUFiles\Programs, and .dll in C:\ECUFiles\TDBDLL\
copy .\Target\Controller_027_DEV.srz C:\ECUFiles\Programs\Controller_027.srz
@echo ### Created Development Executable: Controller_027.srz
copy .\TDB\Controlle_027.dll C:\ECUFiles\TDBDLL\\Controlle_027.dll
@echo ### Created MotoTune DLL: Controlle_027.dll




