summaryrefslogtreecommitdiff
path: root/config.mk
diff options
context:
space:
mode:
authorArseney300 <Arseney300@gmail.com>2026-03-29 02:07:17 +0700
committerArseney300 <Arseney300@gmail.com>2026-04-08 01:19:07 +0700
commit4912796d2e88c6eb5d02fbf0fb9c39f8c9f7cd4c (patch)
tree9ee8110e2c090c888f23797cda56c7e2df531695 /config.mk
bastion: initial implementation
ready project skeleton dual-arch build system with Linux-config style configuration UEFI EFI stub loader (PE32+) for x86_64 and AArch64 ELF64 kernel parser Temporary framebuffer console freestanding string and c++ abi stubs For now, kernel boots, prints banner, memory map and go halt
Diffstat (limited to 'config.mk')
-rw-r--r--config.mk70
1 files changed, 70 insertions, 0 deletions
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..334ca1e
--- /dev/null
+++ b/config.mk
@@ -0,0 +1,70 @@
+# ============================================================================
+# config.mk - Shared Build Configuration
+# ============================================================================
+
+PROJECT_ROOT := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
+
+CC := clang
+CXX := clang++
+AS := clang
+LD := ld.lld
+OBJCOPY := llvm-objcopy
+AR := llvm-ar
+
+ifeq ($(ARCH),x86_64)
+ TARGET_TRIPLE := x86_64-elf
+ EFI_ARCH := x86_64
+ EFI_BINARY := BOOTX64.EFI
+ ARCH_CFLAGS := -target x86_64-unknown-elf \
+ -mno-red-zone \
+ -mno-sse -mno-sse2 -mno-avx \
+ -mcmodel=kernel
+ QEMU := qemu-system-x86_64
+else ifeq ($(ARCH),aarch64)
+ TARGET_TRIPLE := aarch64-elf
+ EFI_ARCH := aarch64
+ EFI_BINARY := BOOTAA64.EFI
+ ARCH_CFLAGS := -target aarch64-unknown-elf \
+ -mgeneral-regs-only
+ QEMU := qemu-system-aarch64
+else
+ $(error ARCH must be x86_64 or aarch64)
+endif
+
+COMMON_CXXFLAGS := \
+ -std=c++23 \
+ -ffreestanding \
+ -fno-exceptions \
+ -fno-rtti \
+ -fno-stack-protector \
+ -fno-threadsafe-statics \
+ -fno-use-cxa-atexit \
+ -fno-pic \
+ -fno-pie \
+ -nostdlib \
+ -nostdinc++ \
+ -Wall -Wextra -Wpedantic \
+ -Werror=return-type \
+ -O2 \
+ -g \
+ -include $(PROJECT_ROOT)/include/kernel/config.h
+
+COMMON_CFLAGS := \
+ -std=c17 \
+ -ffreestanding \
+ -fno-stack-protector \
+ -fno-pic \
+ -fno-pie \
+ -nostdlib \
+ -Wall -Wextra \
+ -O2 \
+ -g
+
+COMMON_ASFLAGS := \
+ -g \
+ -include $(PROJECT_ROOT)/include/kernel/config.h
+
+COMMON_LDFLAGS := \
+ -nostdlib \
+ --no-dynamic-linker \
+ -z noexecstack