@ECHO OFF
REM This file was generated by 'Prog_Generator_MobaLedLib.xlsm'  13:12:05
CHCP 65001 >NUL

color 79
set scriptDir=%~d0%~p0
set errorfile="%~d0%~p0\result.txt"
%~d0
cd "%~p0"
set packagePath=%USERPROFILE%\\AppData\Local\Arduino15\
set toolPath=C:\Program Files (x86)\Arduino\hardware\tools\avr\bin
set platformPath=C:\Program Files (x86)\Arduino\hardware\arduino\avr
set libraryPath=C:\Users\JRGEN~1\DOCUME~1\Arduino\LIBRAR~1
"%toolPath%/avr-g++" -c -g -Os -Wall -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-I%platformPath%\cores\\arduino" "-I%platformPath%\variants\\eightanaloginputs"  "-I%libraryPath%\MobaLedLib\src"  "%scriptDir%Configuration.cpp" -o "%scriptDir%Configuration.cpp.o"
if errorlevel 1 goto :error
"%toolPath%/avr-gcc" -Wall -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p -o "%scriptDir%Configuration.elf" "%scriptDir%Configuration.cpp.o" -lm
if errorlevel 1 goto :error

Rem "%toolPath%/avr-readelf" -a "%scriptDir%Configuration.elf" >"%scriptDir%Configuration.elf.txt"

"%toolPath%/avr-objcopy" -O binary -j .MLLLedConfig "%scriptDir%Configuration.elf" "%scriptDir%LEDConfig.bin"
if errorlevel 1 goto :error
"%toolPath%/avr-objcopy" -O binary -j .MLLAddressConfig "%scriptDir%Configuration.elf" "%scriptDir%AddressConfig.bin"
if errorlevel 1 goto :error
"%toolPath%/avr-objcopy" -O binary -j .MLLL2VConfig "%scriptDir%Configuration.elf" "%scriptDir%L2VConfig.bin"
if errorlevel 1 goto :error
if exist %errorfile% del  %errorfile%
goto :eof

:error
if not "%1"=="silent" (
   COLOR 4F
   ECHO   ****************************************
   ECHO    Da ist was schief gegangen ;-(
   ECHO   ****************************************
   Pause
)
echo fail>%errorfile%
exit /b 1
