aboutsummaryrefslogtreecommitdiff
path: root/makefile
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2021-01-31 23:24:42 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2021-01-31 23:24:42 +0200
commit950f164a2eb851dbab0aacb44334f0b687d123e8 (patch)
treea31c6e3140de2b208eca99e82535d740e9ca4039 /makefile
parentInitial commit (diff)
downloadkernel.cpp-950f164a2eb851dbab0aacb44334f0b687d123e8.tar.xz
libk: add its own makefile
Diffstat (limited to 'makefile')
-rw-r--r--makefile35
1 files changed, 21 insertions, 14 deletions
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