summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorCarlos Maiolino <[email protected]>2025-07-20 14:38:22 +0200
committerCarlos Maiolino <[email protected]>2025-07-20 14:41:57 +0200
commitc6882778696fe40b799887d35ec3f4b48792abaf (patch)
tree6d6dfd7f2316cbcc203c1c2c97be6ed9cbff6698 /Makefile
parent49776b17697afb8f9b4f7c5689d16a44633aed48 (diff)
Add kernel.c
Create the kernel.c file and its initial start_kernel(), and jump to it from the ASM. Also setup the build system to actually build it Signed-off-by: Carlos Maiolino <[email protected]>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile20
1 files changed, 16 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index c43d848..eccede7 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,12 @@
-FILLES = ./build/kernel.asm.o
+FILLES = ./build/kernel.asm.o ./build/kernel.o
+INCLUDES= -I./src/include
+FLAGS= -g -ffreestanding -falign-jumps -falign-functions \
+ -falign-labels -falign-loops -fstrength-reduce \
+ -fomit-frame-pointer -finline-functions \
+ -Wno-unused-function -fno-builtin -Werror \
+ -Wno-unused-label -Wno-cpp -Wno-unused-parameter \
+ -nostdlib -nostartfiles -nodefaultlibs -Wall -O0 -Iinc \
+
BOOTLOADER=./src/boot/bootloader.asm
TARGET=./bin/boot.bin
@@ -8,9 +16,9 @@ all: ./bin/boot.bin ./bin/kernel.bin
dd if=./bin/boot.bin >> ./bin/os.bin
dd if=./bin/kernel.bin >> ./bin/os.bin
dd if=/dev/zero bs=512 count=100 >> ./bin/os.bin
-./bin/kernel.bin: ./build/kernel.asm.o
- i686-elf-ld -g -relocatable ./build/kernel.asm.o -o ./build/cemOS.o
- i686-elf-gcc -T ./src/linker.ld -o ./bin/kernel.bin -ffreestanding -O0 -nostdlib ./build/cemOS.o
+./bin/kernel.bin: ./build/kernel.asm.o ./build/kernel.o
+ i686-elf-ld -g -relocatable ./build/kernel.asm.o ./build/kernel.o -o ./build/cemOS.o
+ i686-elf-gcc $(FLAGS) -T ./src/linker.ld -o ./bin/kernel.bin -ffreestanding -O0 -nostdlib ./build/cemOS.o
./bin/boot.bin: ./src/boot/bootloader.asm
nasm -f bin $(BOOTLOADER) -o $(TARGET)
@@ -18,9 +26,13 @@ all: ./bin/boot.bin ./bin/kernel.bin
./build/kernel.asm.o: ./src/kernel.asm
nasm -f elf -g ./src/kernel.asm -o ./build/kernel.asm.o
+./build/kernel.o: ./src/kernel.c
+ i686-elf-gcc $(INCLUDES) $(FLAGS) -std=gnu99 -c ./src/kernel.c -o ./build/kernel.o
+
clean:
rm -f $(TARGET)
rm -f bin/kernel.bin
rm -f build/cemOS.o
rm -f build/kernel.asm.o
+ rm -f build/kernel.o
rm -f bin/os.bin