summaryrefslogtreecommitdiff
path: root/makefile
diff options
context:
space:
mode:
Diffstat (limited to 'makefile')
-rw-r--r--makefile48
1 files changed, 48 insertions, 0 deletions
diff --git a/makefile b/makefile
new file mode 100644
index 0000000..9497d2c
--- /dev/null
+++ b/makefile
@@ -0,0 +1,48 @@
+GPP_ARGS = -Wall -Wextra -O3 -ggdb -I include -ffreestanding -mno-sse
+KERNEL_OBJECTS = entry.cpp framebuffer.cpp paging.asm paging.cpp terminal.cpp utility.cpp
+
+all: out/disk.iso
+
+run: out/disk.iso
+ gdb -x qemu.gdb
+
+clean:
+ rm -rf obj out
+
+dist-clean:
+ rm -rf limine
+ rm -f include/mercury/kernel/limine.hpp
+
+limine:
+ git clone --depth=1 -b v6.x-branch https://github.com/limine-bootloader/limine.git limine
+ cd limine && ./bootstrap && ./configure -q --enable-bios --enable-bios-cd
+ +make -C limine
+ cp limine/limine.h include/mercury/kernel/limine.hpp
+
+obj/kernel/entry.cpp.o: kernel/entry.cpp limine
+ @mkdir -p $(@D)
+ g++ -c ${GPP_ARGS} $< -o $@
+
+obj/kernel/%.cpp.o: kernel/%.cpp
+ @mkdir -p $(@D)
+ g++ -c ${GPP_ARGS} $< -o $@
+
+obj/kernel/%.asm.o: kernel/%.asm
+ @mkdir -p $(@D)
+ nasm -f elf64 $< -o $@
+
+obj/kernel.elf: ${KERNEL_OBJECTS:%=obj/kernel/%.o}
+ ld -T kernel/link.ld $^ -o $@
+
+obj/initfs.tgz:
+ @mkdir -p obj/initfs
+ echo test > obj/initfs/test.txt
+ cd obj/initfs && tar czf ../initfs.tgz *
+
+out/disk.iso: obj/kernel.elf obj/initfs.tgz limine
+ mkdir -p obj/iso out
+ cp obj/kernel.elf obj/initfs.tgz limine/bin/limine-bios.sys limine/bin/limine-bios-cd.bin limine.cfg obj/iso/
+ cp terminus/ter-u16b.psf obj/iso/termfont.psf
+ xorriso -as mkisofs -quiet -no-emul-boot -boot-info-table -boot-load-size 4 -b limine-bios-cd.bin obj/iso -o $@
+ limine/bin/limine bios-install $@
+ rm -rf obj/iso