Changed to using Boch to better handle debugging the kernel. Updated build system with a new script to handle working with the build_numbers.c file.

This commit is contained in:
2020-05-07 19:24:42 -05:00
parent 4616ce63b3
commit e1a1169240
11 changed files with 80 additions and 63 deletions
+13 -30
View File
@@ -1,55 +1,38 @@
.DELETE_ON_ERROR:
CC = gcc
GCCPARAMS = -m32 -fno-pie -nostdlib -fstrength-reduce -fomit-frame-pointer -finline-functions -fno-builtin -nostdinc -fno-stack-protector
ASPARAMS = -f elf32
LDPARAMS = -m elf_i386
INCBULDNUM = sh make_buildnum.sh
SRC := kernel
OBJ := obj
SOURCES := $(wildcard $(SRC)/*.c)
ASMSOURCES := $(wildcard $(SRC)/*.asm)
ASMSOURCES := $(wildcard $(SRC)/*.s)
OBJECTS := $(patsubst $(SRC)/%.c, $(OBJ)/%.o, $(SOURCES))
ASMOBJECTS := $(patsubst $(SRC)/%.asm, $(OBJ)/%.o, $(ASMSOURCES))
ASMOBJECTS := $(patsubst $(SRC)/%.s, $(OBJ)/%.o, $(ASMSOURCES))
run:kernel.iso
qemu-system-x86_64 -serial pipe:/tmp/guest -m 256M -cdrom kernel.iso &
run: kernel.iso
bochs -f support_files/boch.txt -q
$(OBJ)/%.o: $(SRC)/%.c
mkdir -p $(@D)
$(CC) $(GCCPARAMS) $(SRC) -c -o $@ $<
$(OBJ)/%.o: $(SRC)/%.asm
mkdir -p $(@D)
$(OBJ)/%.o: $(SRC)/%.s
nasm $(ASPARAMS) -o $@ $<
kernel.bin: $(OBJECTS) $(ASMOBJECTS)
@#Crap way to increment the build number, but will do for now
@#thanks to my limited knowledge of Makefiles.
@#Sadly this number in the compiled code will always be off by one with this method....
@sh make_buildnum.sh
mkdir -p obj/bin
ld $(LDPARAMS) -T linker.ld -o obj/bin/$@ $(OBJECTS) $(ASMOBJECTS)
kernel.o: build_numbers.c $(OBJECTS) $(ASMOBJECTS)
@sh support_files/run_linker.sh "$(LDPARAMS)" obj/bin/$@ "$(OBJECTS)" "$(ASMOBJECTS)"
kernel.iso: kernel.bin
mkdir iso
mkdir iso/boot
mkdir iso/boot/grub
cp obj/bin/kernel.bin iso/boot/kernel.bin
echo 'set timeout=0' > iso/boot/grub/grub.cfg
echo 'set default=0' >> iso/boot/grub/grub.cfg
echo '' >> iso/boot/grub/grub.cfg
echo 'menuentry "SDOS" {' >> iso/boot/grub/grub.cfg
echo ' multiboot /boot/kernel.bin' >> iso/boot/grub/grub.cfg
echo ' boot' >> iso/boot/grub/grub.cfg
echo '}' >> iso/boot/grub/grub.cfg
kernel.iso: kernel.o
cp obj/bin/kernel.o iso/boot/kernel.bin
grub-mkrescue --output=kernel.iso iso
rm -rf iso
.PHONY: clean
clean:
rm -rf obj/* kernel.iso
.PHONY: resetbuild
resetbuild:
echo 0 > build.number
@sh support_files/handle_build_numbers.sh build_numbers.c reset