diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-05-03 01:44:31 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-05-03 01:44:31 +0800 |
| commit | 4b1b9912caf41fa52818e5d84130016ce00888cc (patch) | |
| tree | d354df0ee842e51ddfd97fc31c46739dc6edff95 /na/Makefile | |
| parent | 781c48e143ceef05ced5b3f4c9689c209ddf18ee (diff) | |
| download | lume-4b1b9912caf41fa52818e5d84130016ce00888cc.tar.gz lume-4b1b9912caf41fa52818e5d84130016ce00888cc.tar.xz | |
feat: add Kconfig infrastructure for kernel configuration management
Diffstat (limited to 'na/Makefile')
| -rw-r--r-- | na/Makefile | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/na/Makefile b/na/Makefile index e20526a..100bc6d 100644 --- a/na/Makefile +++ b/na/Makefile @@ -16,8 +16,12 @@ # ============================================================ # Build Configuration # ============================================================ -ARCH ?= riscv BUILD := build + +# Load Kconfig infrastructure (reads .config, sets KCPPFLAGS) +include scripts/Kconfig.mk + +ARCH ?= $(CONFIG_ARCH) TARGET := $(BUILD)/kernel.elf IMAGE := $(BUILD)/kernel.bin LDS_SRC := arch/$(ARCH)/kernel/lumeos.lds.S @@ -74,11 +78,13 @@ include lib/module.mk include test/module.mk # Compiler flags (defined AFTER includes so INCLUDES is complete) -CFLAGS := $(WARNINGS) -O2 -g -DDEBUG \ +CFLAGS := $(WARNINGS) -O2 -g \ -ffreestanding -nostdlib \ -mcmodel=medany \ -MMD -MP \ - $(INCLUDES) + $(KCPPFLAGS) \ + $(INCLUDES) \ + -I$(BUILD)/generated # C flags for musl libc sources: add libc-shim headers first CFLAGS_LIBC := $(CFLAGS) -Iinclude/libc-shim \ @@ -106,10 +112,17 @@ DEPS := $(OBJS:.o=.d) # ============================================================ # Build Rules # ============================================================ -.PHONY: all clean run debug fmt disasm +.PHONY: all clean run debug fmt disasm defconfig savedefconfig showconfig all: $(IMAGE) +# Generate autoconf.h before any compilation +$(AUTOCONF_H): scripts/Kconfig.mk $(wildcard .config) + $(generate-autoconf) + +# All objects depend on autoconf.h +$(OBJS): $(AUTOCONF_H) + # Preprocess linker script template (.lds.S → .lds) $(LINKER_SCRIPT): $(LDS_SRC) include/lume/lumeos.lds.h @echo " LDS $@" @@ -207,3 +220,4 @@ info: @echo "SRCS_CC = $(SRCS_CC)" @echo "SRCS_S = $(SRCS_S)" @echo "OBJS = $(OBJS)" + @echo "KCPPFLAGS = $(KCPPFLAGS)" |
