Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- set CAKEOS=E:\cakeOS
- set BUILD_DIR=%CAKEOS%\build
- set LD=ld.exe
- set LDSCRIPT=%BUILD_DIR%\linker.temp
- set GCC=gcc.exe
- set BFI=%BUILD_DIR%\bfi.exe
- set NASM=%BUILD_DIR%\nasm.exe
- :build_boot
- echo/|set /p="[CAKEOS] Building cakeOS/boot "
- for /R %CAKEOS%\boot\ %%I in (*.asm) do %NASM% -f bin ^
- -I%CAKEOS%\ -I%CAKEOS%\boot\ -o %BUILD_DIR%\bin\%%~nI.bin %%I
- echo [OK]
- :build_lvl0
- set LVL=lvl0
- echo/|set /p="[CAKEOS] Building cakeOS/%LVL% "
- for /R %CAKEOS%\%LVL%\ %%I in (*.asm) do %NASM% -f elf32 ^
- -I%CAKEOS%\ -I%CAKEOS%\%LVL%\ -o %BUILD_DIR%\%LVL%.%%~nI.o %%I
- for /R %CAKEOS%\%LVL%\ %%I in (*.c) do gcc.exe -fno-leading-underscore -ffreestanding -c ^
- -I%CAKEOS% -I%CAKEOS%\%LVL%\ -o %BUILD_DIR%\%LVL%.%%~nI.o %%I
- echo [OK]
- :link_lvl0
- set LVL=lvl0
- echo/|set /p="[CAKEOS] Linking cakeOS/%LVL% "
- if not exist %BUILD_DIR%\%LVL%.watchdog.o goto _link_lvl0_nowatchdog
- echo STARTUP(%LVL%.watchdog.o) > %LDSCRIPT%
- echo ENTRY(watchdog_main) >> %LDSCRIPT%
- for /R %BUILD_DIR%\ %%I in (%LVL%.*.o) do if ^
- not %%~nI==%LVL%.watchdog echo INPUT(%%~nI.o) >> %LDSCRIPT%
- goto _link_lvl0_sections
- :_link_lvl0_nowatchdog
- echo STARTUP(%LVL%.%LVL%.o) > %LDSCRIPT%
- echo ENTRY(%LVL%_main) >> %LDSCRIPT%
- for /R %BUILD_DIR%\ %%I in (%LVL%.*.o) do if ^
- not %%~nI==%LVL%.%LVL% echo INPUT(%%~nI.o) >> %LDSCRIPT%
- :_link_lvl0_sections
- echo SECTIONS >> %LDSCRIPT%
- echo { >> %LDSCRIPT%
- echo .text : { >> %LDSCRIPT%
- echo code = .; _code = .; __code = .; >> %LDSCRIPT%
- echo *(.text) >> %LDSCRIPT%
- echo *(.rodata) >> %LDSCRIPT%
- echo . = ALIGN(4096); >> %LDSCRIPT%
- echo } >> %LDSCRIPT%
- echo .data : { >> %LDSCRIPT%
- echo data = .; _data = .; __data = .; >> %LDSCRIPT%
- echo *(.data) >> %LDSCRIPT%
- echo . = ALIGN(4096); >> %LDSCRIPT%
- echo } >> %LDSCRIPT%
- echo .bss : { >> %LDSCRIPT%
- echo bss = .; _bss = .; __bss = .; >> %LDSCRIPT%
- echo *(.bss) >> %LDSCRIPT%
- echo . = ALIGN(4096); >> %LDSCRIPT%
- echo } >> %LDSCRIPT%
- echo end = .; _end = .; __end = .; >> %LDSCRIPT%
- echo } >> %LDSCRIPT%
- echo OUTPUT(%LVL%.bin) >> %LDSCRIPT%
- ld.exe -L %BUILD_DIR% -o %BUILD_DIR%\bin\%LVL%.bin -T %LDSCRIPT%
- objcopy.exe -O binary %BUILD_DIR%\bin\%LVL%.bin
- del %BUILD_DIR%\%LVL%.*.o
- del %LDSCRIPT%
- echo [OK]
- :build_boot
- echo/|set /p="[CAKEOS] Creating cakeOS floppy "
- %BFI% -t="144" -f=%CAKEOS%\cakeOS.img -b=%BUILD_DIR%\bin\bootloader.bin %BUILD_DIR%\bin\
- echo [OK]
- pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement