From 61b4f7fb29db2e8f8af266fcb0836b6b9232245a Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 31 Jan 2021 22:08:01 +0200 Subject: Initial commit --- makefile | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 makefile (limited to 'makefile') 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 -- cgit v1.2.1