diff options
| -rw-r--r-- | docs/specs/00_conventions.md | 2 | ||||
| -rw-r--r-- | na/Makefile | 38 |
2 files changed, 28 insertions, 12 deletions
diff --git a/docs/specs/00_conventions.md b/docs/specs/00_conventions.md index c7e41c9..47da6f1 100644 --- a/docs/specs/00_conventions.md +++ b/docs/specs/00_conventions.md @@ -278,7 +278,7 @@ Phase 2 全部完成后,从各 spec 中提取汇总为 `docs/specs/lock_orderi |------|------| | 构建系统 | GNU Make (非递归模式) | | 编译器 | `riscv64-*-gcc` / `riscv64-*-g++` | -| C++ 标准 | C++17 (`-std=c++17`) | +| C++ 标准 | C++23 (`-std=c++23`) | | 关键编译选项 | `-ffreestanding -nostdlib -fno-exceptions -fno-rtti -mcmodel=medany` | | 代码格式化 | `clang-format`(`.clang-format` 配置) | | 静态分析 | `clang-tidy`(通过 `bear -- make` 生成 `compile_commands.json`) | diff --git a/na/Makefile b/na/Makefile index cc51a65..e20526a 100644 --- a/na/Makefile +++ b/na/Makefile @@ -14,9 +14,20 @@ # Reference: docs/specs/00_conventions.md §7 # ============================================================ +# Build Configuration +# ============================================================ +ARCH ?= riscv +BUILD := build +TARGET := $(BUILD)/kernel.elf +IMAGE := $(BUILD)/kernel.bin +LDS_SRC := arch/$(ARCH)/kernel/lumeos.lds.S +LINKER_SCRIPT := $(BUILD)/lumeos.lds + +# ============================================================ # Toolchain Detection # ============================================================ ifndef TOOLCHAIN_PREFIX +ifeq ($(ARCH),riscv) TOOLCHAIN_PREFIX := $(shell \ if command -v riscv64-linux-gnu-gcc >/dev/null 2>&1; then \ echo riscv64-linux-gnu-; \ @@ -27,6 +38,11 @@ ifndef TOOLCHAIN_PREFIX else \ echo riscv64-linux-gnu-; \ fi) +else ifeq ($(ARCH),aarch64) + TOOLCHAIN_PREFIX := aarch64-linux-gnu- +else ifeq ($(ARCH),x86_64) + TOOLCHAIN_PREFIX := x86_64-linux-gnu- +endif endif CC := $(TOOLCHAIN_PREFIX)gcc @@ -35,16 +51,6 @@ LD := $(TOOLCHAIN_PREFIX)ld OBJCOPY := $(TOOLCHAIN_PREFIX)objcopy OBJDUMP := $(TOOLCHAIN_PREFIX)objdump -# ============================================================ -# Build Configuration -# ============================================================ -ARCH := riscv -BUILD := build -TARGET := $(BUILD)/kernel.elf -IMAGE := $(BUILD)/kernel.bin -LDS_SRC := arch/$(ARCH)/kernel/lumeos.lds.S -LINKER_SCRIPT := $(BUILD)/lumeos.lds - # Common flags (base, before module includes) WARNINGS := -Wall -Wextra -Wno-unused-parameter INCLUDES := -Iinclude -I. @@ -58,7 +64,7 @@ SRCS_C := SRCS_S := SRCS_s := -include arch/$(ARCH)/module.mk +-include arch/$(ARCH)/module.mk include kernel/module.mk include mm/module.mk # include fs/module.mk # Phase 3 @@ -152,9 +158,19 @@ $(BUILD)/%.o: %.s # ============================================================ # Run & Debug # ============================================================ +ifeq ($(ARCH),riscv) QEMU := qemu-system-riscv64 QEMU_MACHINE := -machine virt -m 128M -nographic QEMU_BIOS := -bios default +else ifeq ($(ARCH),aarch64) +QEMU := qemu-system-aarch64 +QEMU_MACHINE := -machine virt -cpu cortex-a53 -m 128M -nographic +QEMU_BIOS := +else ifeq ($(ARCH),x86_64) +QEMU := qemu-system-x86_64 +QEMU_MACHINE := -m 128M -nographic +QEMU_BIOS := +endif run: $(IMAGE) @echo " QEMU Running..." |
