Advertisement
captmicro

Untitled

Mar 26th, 2011
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. set CAKEOS=E:\cakeOS
  3. set BUILD_DIR=%CAKEOS%\build
  4. set LD=ld.exe
  5. set LDSCRIPT=%BUILD_DIR%\linker.temp
  6. set GCC=gcc.exe
  7. set BFI=%BUILD_DIR%\bfi.exe
  8. set NASM=%BUILD_DIR%\nasm.exe
  9.  
  10. :build_boot
  11. echo/|set /p="[CAKEOS] Building cakeOS/boot "
  12. for /R %CAKEOS%\boot\ %%I in (*.asm) do %NASM% -f bin ^
  13.  -I%CAKEOS%\ -I%CAKEOS%\boot\ -o %BUILD_DIR%\bin\%%~nI.bin %%I
  14. echo [OK]
  15.  
  16. :build_lvl0
  17. set LVL=lvl0
  18. echo/|set /p="[CAKEOS] Building cakeOS/%LVL% "
  19. for /R %CAKEOS%\%LVL%\ %%I in (*.asm) do %NASM% -f elf32 ^
  20.  -I%CAKEOS%\ -I%CAKEOS%\%LVL%\ -o %BUILD_DIR%\%LVL%.%%~nI.o %%I
  21. for /R %CAKEOS%\%LVL%\ %%I in (*.c) do gcc.exe -fno-leading-underscore -ffreestanding -c ^
  22.  -I%CAKEOS% -I%CAKEOS%\%LVL%\ -o %BUILD_DIR%\%LVL%.%%~nI.o %%I
  23. echo [OK]
  24.  
  25. :link_lvl0
  26. set LVL=lvl0
  27. echo/|set /p="[CAKEOS] Linking cakeOS/%LVL% "
  28. if not exist %BUILD_DIR%\%LVL%.watchdog.o goto _link_lvl0_nowatchdog
  29. echo STARTUP(%LVL%.watchdog.o) > %LDSCRIPT%
  30. echo ENTRY(watchdog_main) >> %LDSCRIPT%
  31. for /R %BUILD_DIR%\ %%I in (%LVL%.*.o) do if ^
  32.  not %%~nI==%LVL%.watchdog echo INPUT(%%~nI.o) >> %LDSCRIPT%
  33. goto _link_lvl0_sections
  34. :_link_lvl0_nowatchdog
  35. echo STARTUP(%LVL%.%LVL%.o) > %LDSCRIPT%
  36. echo ENTRY(%LVL%_main) >> %LDSCRIPT%
  37. for /R %BUILD_DIR%\ %%I in (%LVL%.*.o) do if ^
  38.  not %%~nI==%LVL%.%LVL% echo INPUT(%%~nI.o) >> %LDSCRIPT%
  39. :_link_lvl0_sections
  40. echo SECTIONS >> %LDSCRIPT%
  41. echo { >> %LDSCRIPT%
  42. echo    .text  : { >> %LDSCRIPT%
  43. echo        code = .; _code = .; __code = .; >> %LDSCRIPT%
  44. echo        *(.text) >> %LDSCRIPT%
  45. echo        *(.rodata) >> %LDSCRIPT%
  46. echo        . = ALIGN(4096); >> %LDSCRIPT%
  47. echo    } >> %LDSCRIPT%
  48. echo    .data  : { >> %LDSCRIPT%
  49. echo        data = .; _data = .; __data = .; >> %LDSCRIPT%
  50. echo        *(.data) >> %LDSCRIPT%
  51. echo        . = ALIGN(4096); >> %LDSCRIPT%
  52. echo    } >> %LDSCRIPT%
  53. echo    .bss  : { >> %LDSCRIPT%
  54. echo        bss = .; _bss = .; __bss = .; >> %LDSCRIPT%
  55. echo        *(.bss) >> %LDSCRIPT%
  56. echo        . = ALIGN(4096); >> %LDSCRIPT%
  57. echo    } >> %LDSCRIPT%
  58. echo    end = .; _end = .; __end = .; >> %LDSCRIPT%
  59. echo } >> %LDSCRIPT%
  60. echo OUTPUT(%LVL%.bin) >> %LDSCRIPT%
  61. ld.exe -L %BUILD_DIR% -o %BUILD_DIR%\bin\%LVL%.bin -T %LDSCRIPT%
  62. objcopy.exe -O binary %BUILD_DIR%\bin\%LVL%.bin
  63. del %BUILD_DIR%\%LVL%.*.o
  64. del %LDSCRIPT%
  65. echo [OK]
  66.  
  67. :build_boot
  68. echo/|set /p="[CAKEOS] Creating cakeOS floppy "
  69. %BFI% -t="144" -f=%CAKEOS%\cakeOS.img -b=%BUILD_DIR%\bin\bootloader.bin %BUILD_DIR%\bin\
  70. echo [OK]
  71.  
  72. pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement