@echo off

:BOOT
echo compiling /boot...
cd boot
..\tools\nasm -f aout -o start.o start.asm
copy  *.o ..\bin
del *.o
cd ..






:KERNEL
echo compiling /kernel...
cd kernel
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I../include -c -o mm.o mm.c

gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I../include -c -o io.o io.c

gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I../include -c -o scrn.o scrn.c

gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I../include -c -o gdt.o gdt.c

gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I../include -c -o idt.o idt.c

gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I../include -c -o isrs.o isrs.c

gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I../include -c -o irq.o irq.c

gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I../include -c -o kb.o kb.c

gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I../include -c -o oa.o oa.c

..\tools\nasm -f aout -o interrupt.o interrupt.asm

copy *.o ..\bin
del *.o
cd ..


:INIT
cd init
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I../include -c -o init.o init.c
copy *.o ..\bin
del *.o
cd ..

:LIB
cd lib
gcc -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I../include -c -o video.o video.c
copy  *.o ..\bin
del *.o
cd ..

:FS
cd fs
gcc -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I../include -c -o fs.o fs.c
copy *.o ..\bin
del *.o
cd ..

:BIN
echo Linking...
cd bin
..\tools\ld -T link.ld -o NJkernel.bin start.o mm.o scrn.o gdt.o idt.o isrs.o irq.o kb.o init.o io.o interrupt.o video.o fs.o
echo Cleaning up object files...
del *.o


echo Done!
pause
