diff --git a/Makefile b/Makefile index f678886..045fd89 100644 --- a/Makefile +++ b/Makefile @@ -51,19 +51,11 @@ all: kern/kernel.elf quickstart: make get_toolchain && bear -- make -j$(nproc) && make qemu -KERNEL_OBJ := \ - kern/entry.o \ - kern/start.o \ - kern/kalloc.o \ - kern/libkern/string.o \ - kern/libkern/proc.o \ - kern/libkern/uart.o \ - kern/libkern/panic.o \ - kern/libkern/memory.o \ - kern/libkern/spinlock.o \ - kern/libkern/mini-printf.o \ - kern/libkern/stdio.o \ - kern/libkern/badrand.o +SUBDIRS := kern + +include $(patsubst %, %/include.mk, $(SUBDIRS)) + +KERNEL_OBJ := $(KERN_OBJ) kern/kernel.elf: $(KERNEL_OBJ) @echo LD $@ diff --git a/README.md b/README.md index 8d95e18..c7afa7d 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ On a linux machine, make sure that you have `make` and `curl` in path. The rest of the tooling (gcc, qemu) will be handled by the build system. For extra convenience, you could also use `bear` for generating "compile_commands.json". This is useful for helping clangd pick up the correct paths, and will result in better in-editor diagnostics and warnings. +clang-format and find might also be useful for development. ```sh make get_toolchain # Dont worry, is will land locally inside project directory diff --git a/kern/include.mk b/kern/include.mk new file mode 100644 index 0000000..8496555 --- /dev/null +++ b/kern/include.mk @@ -0,0 +1,9 @@ +KERN_SRC := $(wildcard kern/*.c) +KERN_SRC += $(wildcard kern/*.S) + +KERN_OBJ := $(KERN_SRC:.c=.o) +KERN_OBJ := $(KERN_OBJ:.S=.o) + +include kern/libkern/include.mk + +KERN_OBJ += $(LIBKERN_OBJ) diff --git a/kern/libkern/include.mk b/kern/libkern/include.mk new file mode 100644 index 0000000..491b247 --- /dev/null +++ b/kern/libkern/include.mk @@ -0,0 +1,5 @@ +LIBKERN_SRC := $(wildcard kern/libkern/*.c) +LIBKERN_SRC += $(wildcard kern/libkern/*.S) + +LIBKERN_OBJ := $(LIBKERN_SRC:.c=.o) +LIBKERN_OBJ := $(LIBKERN_OBJ:.S=.o)