diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2021-01-31 22:08:01 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2021-01-31 22:08:01 +0200 |
commit | 61b4f7fb29db2e8f8af266fcb0836b6b9232245a (patch) | |
tree | c5aa7d9049cbeb60e17e8440ac8eb0f79decf66b /makefile | |
download | kernel.cpp-61b4f7fb29db2e8f8af266fcb0836b6b9232245a.tar.xz |
Initial commit
Diffstat (limited to 'makefile')
-rw-r--r-- | makefile | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/makefile b/makefile new file mode 100644 index 0000000..82e3bba --- /dev/null +++ b/makefile @@ -0,0 +1,41 @@ +# https://www.gnu.org/software/make/manual/html_node/Setting.html +# := expanded variable, right-hand side can contain variables +# ?= only set if it doesn't have a value +# != execute a shell script on the right-hand side and assign its result to the left-hand side + +TARGET := i686-elf + +NASM := nasm +CXX := clang++ +CXXFLAGS := -std=c++20 -ffreestanding -nostdinc -fno-exceptions -fno-rtti -Wall -Wextra -O2 +INCLUDE := stdlib + +OBJ := kernel.o vga.o stdlib/string.o stdlib/stdlib/console.o + +# $@ is target +# $< is first dependency +# $^ is all dependencies + +default: boot.o $(OBJ) + ld.lld -T linker.ld -o myos.bin boot.o $(OBJ) + +boot.o: boot.asm + $(NASM) -felf32 -o $@ $^ + +$(OBJ): %.o : %.cc + $(CXX) -target $(TARGET) $(CXXFLAGS) -I$(INCLUDE) -c $^ -o $@ + +iso: + mkdir -p isodir/boot/grub + cp myos.bin isodir/boot/myos.bin + cp grub.cfg isodir/boot/grub/grub.cfg + grub-mkrescue -o myos.iso isodir + +run: + qemu-system-i386 -kernel myos.bin + +clean: + rm boot.o $(OBJ) myos.bin + +clean-iso: + rm -rf isodir |