diff options
Diffstat (limited to 'makefile')
-rw-r--r-- | makefile | 35 |
1 files changed, 21 insertions, 14 deletions
@@ -3,39 +3,46 @@ # ?= 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 +export 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 +export AR := llvm-ar +export NASM := nasm +export LD := ld.lld +export CXX := clang++ +export CXX_FLAGS := -std=c++20 -ffreestanding -nostdinc -fno-exceptions -fno-rtti -Wall -Wextra -O2 +CXX_INCLUDE := libk +CXX_OBJ := kernel.o vga.o # $@ is target # $< is first dependency # $^ is all dependencies -default: boot.o $(OBJ) - ld.lld -T linker.ld -o myos.bin boot.o $(OBJ) +default: myos.bin + +myos.bin: boot.o $(CXX_OBJ) libk/libk.a + $(LD) -T linker.ld -o myos.bin boot.o $(CXX_OBJ) -Llibk -lk boot.o: boot.asm $(NASM) -felf32 -o $@ $^ -$(OBJ): %.o : %.cc - $(CXX) -target $(TARGET) $(CXXFLAGS) -I$(INCLUDE) -c $^ -o $@ +$(CXX_OBJ): %.o : %.cc + $(CXX) -target $(TARGET) $(CXX_FLAGS) -I$(CXX_INCLUDE) -c $^ -o $@ + +libk/libk.a: + $(MAKE) -C libk libk.a -iso: +iso: myos.bin 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: +run: myos.bin qemu-system-i386 -kernel myos.bin clean: - rm boot.o $(OBJ) myos.bin + rm boot.o $(CXX_OBJ) myos.bin + $(MAKE) -C libk clean clean-iso: rm -rf isodir |