From 950f164a2eb851dbab0aacb44334f0b687d123e8 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 31 Jan 2021 23:24:42 +0200 Subject: libk: add its own makefile --- makefile | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'makefile') diff --git a/makefile b/makefile index 82e3bba..10cfacf 100644 --- a/makefile +++ b/makefile @@ -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 -- cgit v1.2.1