@echo off

rem Make sure we are in target directory
call "%~dp0/verify_dir.bat" %1
if %ERRORLEVEL% NEQ 0 exit 1
attrib -R *

rem  Configuration header files

for %%F in (..\..\..\config\common\*.h)     do copy /Y /B ..\..\..\mqx\source\include\dontchg.h + %%F ..\%%~nF%%~xF
for %%F in (..\..\..\config\fxlc95000eval\*.h)  do copy /Y /B ..\..\..\mqx\source\include\dontchg.h + %%F ..\%%~nF%%~xF

rem  Compiler-specific BSP files

if /I "%~2" == "iar" goto comp_iar

rem  CodeWarrior Compiler


:comp_cw
mkdir dbg
rem copy /Y ..\..\..\mqx\source\bsp\fxlc95000eval\cw\intflash.lcf .
copy /Y ..\..\..\mqx\source\bsp\fxlc95000eval\cw\intflash_mqx.lcf .

copy /Y ..\..\..\mqx\source\bsp\fxlc95000eval\cw\dbg\CFV1_PEBDM_Preload.cmd .\dbg
copy /Y ..\..\..\mqx\source\bsp\fxlc95000eval\cw\dbg\CFV1_PEBDM_Reset.cmd .\dbg
copy /Y ..\..\..\mqx\source\bsp\fxlc95000eval\cw\dbg\CFV1_PEBDM_Startup.cmd .\dbg
copy /Y ..\..\..\mqx\source\bsp\fxlc95000eval\cw\dbg\CFV1_PEBDM_Postload.cmd .\dbg
copy /Y ..\..\..\mqx\source\bsp\fxlc95000eval\cw\dbg\CFV1_PEBDM.ini .\dbg 

copy /Y ..\..\..\mqx\source\bsp\fxlc95000eval\cw\dbg\CFV1_OSBDM_Erase_Unsecure.cmd .\dbg
copy /Y ..\..\..\mqx\source\bsp\fxlc95000eval\cw\dbg\CFV1_OSBDM_Postload.cmd .\dbg
copy /Y ..\..\..\mqx\source\bsp\fxlc95000eval\cw\dbg\CFV1_OSBDM_Preload.cmd .\dbg
copy /Y ..\..\..\mqx\source\bsp\fxlc95000eval\cw\dbg\CFV1_OSBDM_Reset.cmd .\dbg
copy /Y ..\..\..\mqx\source\bsp\fxlc95000eval\cw\dbg\CFV1_OSBDM_Startup.cmd .\dbg        
copy /Y ..\..\..\mqx\source\bsp\fxlc95000eval\cw\dbg\CFV1_OSBDM.ini .\dbg

copy /Y ..\..\..\mqx\source\bsp\fxlc95000eval\cw\dbg\Default.mem .\dbg
rem copy /Y ..\..\..\mqx\source\bsp\fxlc95000eval\cw\dbg\fxlc95000eval.cfg .\dbg
rem copy /Y ..\..\..\mqx\source\bsp\fxlc95000eval\cw\dbg\fxlc95000eval.mem .\dbg
goto comp_done

rem  IAR Compiler

:comp_iar
rem TODO: IAR SUPPORT
goto comp_done

rem  End of Compiler-specific files

:comp_done

rem  Board-specific BSP files

copy /Y ..\..\..\mqx\source\bsp\fxlc95000eval\bsp.h .
copy /Y ..\..\..\mqx\source\bsp\fxlc95000eval\bsp_rev.h .
copy /Y ..\..\..\mqx\source\bsp\fxlc95000eval\fxlc95000eval.h .
copy /Y ..\..\..\mqx\source\bsp\fxlc95000eval\fxlc95000bsp.h .
copy /Y ..\..\..\mqx\source\psp\coldfire\fxlc95000.h .
copy /Y ..\..\..\mqx\source\psp\coldfire\fxlc95000_psp.h .



rem  Board-specific IO driver files

copy /Y ..\..\..\mqx\source\include\io_rev.h .
copy /Y ..\..\..\mqx\source\io\int_ctrl\int_ctrl_fxlc95000.h .
copy /Y ..\..\..\mqx\source\io\timer\timer_fxlc95000.h .
copy /Y ..\..\..\mqx\source\io\io_dun\io_dun.h .
copy /Y ..\..\..\mqx\source\io\io_mem\io_mem.h .
copy /Y ..\..\..\mqx\source\io\io_mem\iomemprv.h .
copy /Y ..\..\..\mqx\source\io\pcb\io_pcb.h .
copy /Y ..\..\..\mqx\source\io\pcb\mqxa\pcb_mqxa.h .
copy /Y ..\..\..\mqx\source\io\io_null\io_null.h .
copy /Y ..\..\..\mqx\source\io\gpio\io_gpio.h .
copy /Y ..\..\..\mqx\source\io\gpio\fxlc95xxx\io_gpio_fxlc95000.h .
copy /Y ..\..\..\mqx\source\io\i2c\i2c.h  .
copy /Y ..\..\..\mqx\source\io\i2c\i2c_fxlc95xxx.h .
copy /Y ..\..\..\mqx\source\io\i2c\fxlc95xxx_i2c.h .
copy /Y ..\..\..\mqx\source\io\flashx\flashx.h .
copy /Y ..\..\..\mqx\source\io\flashx\freescale\flash_fxlc95xxx.h .
copy /Y ..\..\..\mqx\source\io\flashx\freescale\flash_fxlc95000.h .

rem  Generate library readme file

call "%~dp0\write_readme.bat" > ..\fxlc95000eval_lib.txt
